Permalink
Browse files

fix striked price WIP

  • Loading branch information...
seb-odoo committed Nov 8, 2018
1 parent f14a41f commit d47127431a7bebe4f4ab96c54a6992e6724ef9c7
@@ -117,3 +117,10 @@ def get_import_templates(self):
'template': '/sale/static/xls/product_pricelist_several.xls'
}]
return res
@api.multi
def _get_combination_info(self, combination, product_id=False, add_qty=1, pricelist=False):
# TODO SEB write a comment and test for this
res = super(ProductTemplate, self)._get_combination_info(combination, product_id, add_qty, pricelist)
res.update(has_price_difference=(pricelist or self).currency_id.compare_amounts(res.get('list_price'), res.get('price')) == 1)
return res
@@ -423,7 +423,11 @@ var ProductConfiguratorMixin = {
var $optional_price = $parent.find(".oe_optional:first .oe_currency_value");
$price.html(self._priceToStr(combination.price));
$default_price.html(self._priceToStr(combination.list_price));
if (combination.list_price - combination.price > 0.01) {
// compatibility_check to remove in master
// needed for fix in 12.0 in the case of git pull and no server restart
var compatibility_check = combination.list_price - combination.price > 0.01;
if (combination.has_price_difference !== undefined ? combination.has_price_difference : compatibility_check) {
$default_price
.closest('.oe_website_sale')
.addClass("discount");
@@ -433,6 +437,9 @@ var ProductConfiguratorMixin = {
.css('text-decoration', 'line-through');
$default_price.parent().removeClass('d-none');
} else {
$default_price
.closest('.oe_website_sale')
.removeClass("discount");
$optional_price.closest('.oe_optional').addClass('d-none');
$default_price.parent().addClass('d-none');
}
@@ -124,6 +124,7 @@ var OptionalProductsModal = Dialog.extend(ServicesMixin, ProductConfiguratorMixi
self.$modal.attr('open', true);
self.$modal.removeAttr("aria-hidden");
self.$modal.modal().appendTo(self.container);
self.$modal.focus();
self._opened.resolve();
}
});
@@ -125,12 +125,7 @@ label.css_attribute_color.css_not_available {
}
.o_total_row {
h5 {
padding-top: 0.4rem;
}
.js_price_total {
font-size: 1.5rem;
}
font-size: 1.5rem;
}
}
@@ -89,7 +89,9 @@
<td class="text-center td-price" name="price">
<ul class="d-none js_add_cart_variants" t-att-data-attribute_exclusions="{'exclusions: []'}"></ul>
<div class="d-none oe_unchanged_value_ids" t-att-data-unchanged_value_ids="variant_values" ></div>
<div t-if="pricelist and pricelist.discount_policy == 'without_discount' and to_currency.compare_amounts(compute_currency(product.lst_price), product.price) == 1" t-attf-class="text-danger oe_default_price oe_striked_price"
<!-- TODO SEB remove compute_currency from parent?? -->
<!-- TODO SEB call _get_combination_info to fix this -->
<div t-attf-class="text-danger oe_default_price oe_striked_price {{'' if product.has_price_difference else 'd-none'}}"
t-field="product.lst_price"
t-options='{
"widget": "monetary",
@@ -107,9 +109,8 @@
</td>
</tr>
<tr class="o_total_row">
<td colspan="2"></td>
<td class="text-right"><h5>Total:</h5></td>
<td class="text-center">
<td colspan="4" class="text-right">
<strong>Total:</strong>
<span class="js_price_total font-weight-bold" style="white-space: nowrap;"
t-att-data-product-id="product.id"
t-esc="product.price"
@@ -146,7 +147,8 @@
</div>
</td>
<td class="text-center td-price">
<span class="text-danger oe_default_price oe_optional"
<!-- TODO SEB call _get_combination_info to fix this -->
<span class="text-danger oe_default_price oe_optional {{'' if product.has_price_difference else 'd-none'}}"
t-field="product.lst_price"
t-options='{
"widget": "monetary",
@@ -178,8 +178,13 @@ def _sort_key_variant(variant):
@api.multi
def _get_combination_info_website(self, combination, product=False, add_qty=1):
"""
Same as _get_combination_info but uses the current website pricelist
and return values tax included or tax excluded depending on setting.
"""
self.ensure_one()
# TODO SEB write test for quantity > 1, also one for _get_combination_info
product = product or self._get_variants_for_combination(combination)[:1]
qty = self._context.get('quantity', add_qty)
@@ -199,20 +204,19 @@ def _get_combination_info_website(self, combination, product=False, add_qty=1):
combination_info = self_with_context._get_combination_info(combination, product_with_context.id, qty, pricelist)
website_price = taxes.compute_all(combination_info.get('price'), pricelist.currency_id, qty, product_with_context or self_with_context, partner)[tax_display]
price = taxes.compute_all(combination_info.get('price'), pricelist.currency_id, 1, product_with_context or self_with_context, partner)[tax_display]
list_price = taxes.compute_all(combination_info.get('list_price'), pricelist.currency_id, 1, product_with_context or self_with_context, partner)[tax_display]
if pricelist.discount_policy == 'without_discount':
combination_info = self._get_combination_info(combination, product.id, qty, None)
lst_price = self_with_context.currency_id._convert(combination_info.get('list_price'), pricelist.currency_id, self.env.user.company_id)
website_public_price = taxes.compute_all(lst_price, pricelist.currency_id, qty, self, partner)[tax_display]
else:
website_public_price = website_price
website_price = taxes.compute_all(combination_info.get('price'), pricelist.currency_id, qty, product_with_context or self_with_context, partner)[tax_display]
website_public_price = taxes.compute_all(combination_info.get('list_price'), pricelist.currency_id, qty, self, partner)[tax_display]
website_price_difference = pricelist.currency_id.compare_amounts(product.website_public_price, product.website_price) == 1
has_price_difference = pricelist.currency_id.compare_amounts(list_price, price) == 1
website_price_difference = pricelist.currency_id.compare_amounts(website_public_price, website_price) == 1
combination_info.update(
price=website_price, # compatibility 12.0
list_price=website_public_price, # compatibility 12.0
price=price,
list_price=list_price,
has_price_difference=has_price_difference,
website_price=website_price,
website_public_price=website_public_price,
website_price_difference=website_price_difference
@@ -122,9 +122,7 @@
</h6>
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price">
<b>
<t t-if="product.website_price_difference">
<del class="text-danger mr8" style="white-space: nowrap;" t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
</t>
<del t-attf-class="text-danger mr8 {{'' if product.website_price_difference else 'd-none'}}" style="white-space: nowrap;" t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
<span t-esc="product.website_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<span itemprop="price" style="display:none;" t-esc="product.website_price" />
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name" />
@@ -599,9 +597,8 @@
<template id="product_price">
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price mt16">
<h4 class="oe_price_h4 css_editable_mode_hidden">
<span class="text-danger oe_default_price" style="text-decoration: line-through; white-space: nowrap;"
t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
t-att-style="'text-decoration: line-through; white-space: nowrap; ' + '' if product.website_price_difference else 'display: none;'"
<span t-attf-class="text-danger oe_default_price {{'' if product.website_price_difference else 'd-none'}}" style="text-decoration: line-through; white-space: nowrap;"
t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
/>
<b class="oe_price" style="white-space: nowrap;" t-esc="product.website_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
<span itemprop="price" style="display:none;" t-esc="product.website_price"/>
@@ -962,9 +959,7 @@
<div class="text-muted d-none d-md-block" t-field="product.description_sale" />
</td>
<td class='td-price'>
<t t-if="product.website_price_difference">
<del class="text-danger mr8" style="white-space: nowrap;" t-field="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
</t>
<del t-attf-class="text-danger mr8 {{'' if product.website_price_difference else 'd-none'}}" style="white-space: nowrap;" t-field="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
<span t-field="product.website_price" style="white-space: nowrap;" t-options="{'widget': 'monetary','display_currency': website.currency_id}" />
</td>
<td class="col-lg-2 col-md-3 col-4 text-center">
@@ -88,9 +88,7 @@
<span>
<strong>Price:</strong>
<t t-if="product.website_price_difference">
<del class="text-danger mr8" style="white-space: nowrap;" t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id" />
</t>
<del t-attfclass="text-danger mr8 {{'' if product.website_price_difference else 'd-none'}}" style="white-space: nowrap;" t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id" />
<span t-esc="product.website_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"></span>
</span>
@@ -129,9 +127,7 @@
<div class="col-8 pl-2">
<h6>
<a t-attf-href="/shop/product/#{product.product_tmpl_id[0].id}"><t t-esc="product.display_name" /></a><br/>
<t t-if="product.website_price_difference">
<del class="text-danger mr8" style="white-space: nowrap;" t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id" />
</t>
<del t-attf-class="text-danger mr8 {{'' if product.website_price_difference else 'd-none'}}" style="white-space: nowrap;" t-esc="product.website_public_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id" />
<span t-esc="product.website_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"></span>
</h6>
</div>

0 comments on commit d471274

Please sign in to comment.