[IMP] website_sale: make compare_list_price visible in comparison
Compare list price as base price or list price in comparison or comparison preview task-2795129 closes odoo/odoo#87134 Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
<tree string="Products Price List" sample="1">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="discount_policy" groups="product.group_discount_per_so_line"/>
|
||||
<field name="discount_policy"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
@@ -45,7 +45,7 @@
|
||||
<i class="fa fa-money" role="img" aria-label="Currency" title="Currency"></i> <field name="currency_id"/>
|
||||
</strong>
|
||||
</div>
|
||||
<field name="discount_policy" groups="product.group_discount_per_so_line"/>
|
||||
<field name="discount_policy"/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -112,7 +112,7 @@
|
||||
<group name="pricelist_availability" string="Availability">
|
||||
<field name="country_group_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
<group name="pricelist_discounts" groups="product.group_discount_per_so_line" string="Discounts">
|
||||
<group name="pricelist_discounts" string="Discounts">
|
||||
<field name="discount_policy" widget="radio"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
</group>
|
||||
<group name="group_standard_price">
|
||||
<label for="list_price" class="mt-1"/>
|
||||
<div name="pricing">
|
||||
<div name="pricing" class="o_row">
|
||||
<field name="list_price" class="oe_inline" widget='monetary'
|
||||
options="{'currency_field': 'currency_id', 'field_digits': True}"/>
|
||||
</div>
|
||||
|
||||
@@ -528,7 +528,7 @@ var VariantMixin = {
|
||||
}
|
||||
this._toggleDisable($parent, isCombinationPossible);
|
||||
|
||||
if (combination.has_discounted_price) {
|
||||
if (combination.has_discounted_price && !combination.compare_list_price) {
|
||||
$default_price
|
||||
.closest('.oe_website_sale')
|
||||
.addClass("discount");
|
||||
|
||||
@@ -53,9 +53,9 @@ class ProductTemplate(models.Model):
|
||||
base_unit_price = fields.Monetary("Price Per Unit", currency_field="currency_id", compute="_compute_base_unit_price")
|
||||
base_unit_name = fields.Char(compute='_compute_base_unit_name', help='Displays the custom unit for the products if defined or the selected unit of measure otherwise.')
|
||||
|
||||
compare_list_price = fields.Float(
|
||||
compare_list_price = fields.Monetary(
|
||||
'Compare to Price',
|
||||
digits='Product Price',
|
||||
currency_field="currency_id",
|
||||
help="The amount will be displayed strikethroughed on the eCommerce product page")
|
||||
|
||||
@api.depends('product_variant_ids', 'product_variant_ids.base_unit_count')
|
||||
@@ -211,6 +211,22 @@ class ProductTemplate(models.Model):
|
||||
base_price = taxes.compute_all(base_price, pricelist.currency_id, 1, template, partner_sudo)[
|
||||
tax_display]
|
||||
template_price_vals['base_price'] = base_price
|
||||
if base_price > price_reduce:
|
||||
base_price = self.env['account.tax']._fix_tax_included_price_company(
|
||||
base_price, product_taxes, taxes, self.env.company)
|
||||
base_price = taxes.compute_all(base_price, pricelist.currency_id, 1, template, partner_sudo)[tax_display]
|
||||
template_price_vals['base_price'] = base_price
|
||||
|
||||
if template.compare_list_price:
|
||||
template_price_vals['base_price'] = template.compare_list_price
|
||||
if template.currency_id != pricelist.currency_id:
|
||||
template_price_vals['base_price'] = template.currency_id._convert(
|
||||
template.compare_list_price,
|
||||
pricelist.currency_id,
|
||||
self.env.company,
|
||||
fields.Datetime.now(),
|
||||
round=False
|
||||
)
|
||||
|
||||
res[template.id] = template_price_vals
|
||||
|
||||
@@ -270,6 +286,12 @@ class ProductTemplate(models.Model):
|
||||
fields.Date.today())
|
||||
has_discounted_price = pricelist.currency_id.compare_amounts(list_price, price) == 1
|
||||
prevent_zero_price_sale = not price and current_website.prevent_zero_price_sale
|
||||
|
||||
compare_list_price = self.compare_list_price
|
||||
if self.currency_id != pricelist.currency_id:
|
||||
compare_list_price = self.currency_id._convert(self.compare_list_price, pricelist.currency_id, self.env.company,
|
||||
fields.Datetime.now(), round=False)
|
||||
|
||||
combination_info.update(
|
||||
base_unit_name=product.base_unit_name,
|
||||
base_unit_price=product.base_unit_count and list_price / product.base_unit_count,
|
||||
@@ -278,6 +300,7 @@ class ProductTemplate(models.Model):
|
||||
price_extra=price_extra,
|
||||
has_discounted_price=has_discounted_price,
|
||||
prevent_zero_price_sale=prevent_zero_price_sale,
|
||||
compare_list_price=compare_list_price,
|
||||
)
|
||||
|
||||
return combination_info
|
||||
@@ -485,6 +508,7 @@ class ProductTemplate(models.Model):
|
||||
)
|
||||
if list_price:
|
||||
data['list_price'] = list_price
|
||||
|
||||
if with_image:
|
||||
data['image_url'] = '/web/image/product.template/%s/image_128' % data['id']
|
||||
if with_category and categ_ids:
|
||||
@@ -507,6 +531,10 @@ class ProductTemplate(models.Model):
|
||||
list_price = self.env['ir.qweb.field.monetary'].value_to_html(
|
||||
combination_info['list_price'], monetary_options
|
||||
)
|
||||
if combination_info['compare_list_price']:
|
||||
list_price = self.env['ir.qweb.field.monetary'].value_to_html(
|
||||
combination_info['compare_list_price'], monetary_options
|
||||
)
|
||||
|
||||
return price, list_price if combination_info['has_discounted_price'] else None
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
<t t-set="template_price_vals" t-value="get_product_prices(product)"/>
|
||||
<div class="o_wsale_product_btn"/>
|
||||
<div class="product_price" itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer">
|
||||
<t t-if="'base_price' in template_price_vals">
|
||||
<t t-if="'base_price' in template_price_vals and template_price_vals['base_price'] > template_price_vals['price_reduce']">
|
||||
<del t-attf-class="text-muted me-1 h6 mb-0" style="white-space: nowrap;">
|
||||
<em class="small" t-esc="template_price_vals['base_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
|
||||
</del>
|
||||
@@ -870,7 +870,7 @@
|
||||
</template>
|
||||
|
||||
<!-- /shop/product page -->
|
||||
<template id="base_unit_price" name="Product Bas eunit price">
|
||||
<template id="base_unit_price" name="Product Base unit price">
|
||||
(<span class="o_base_unit_price" t-esc="combination_info['base_unit_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
|
||||
/ <span class="oe_custom_base_unit" t-field="product.base_unit_name"/>)
|
||||
</template>
|
||||
@@ -1156,17 +1156,19 @@
|
||||
<span class="oe_price" style="white-space: nowrap;" t-esc="combination_info['price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
|
||||
<span itemprop="price" style="display:none;" t-esc="combination_info['price']"/>
|
||||
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name"/>
|
||||
<span t-attf-class="text-danger oe_default_price ms-1 h5 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="text-decoration: line-through; white-space: nowrap;"
|
||||
t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
|
||||
<span t-attf-class="text-danger oe_default_price ms-1 h5 {{'' if combination_info['has_discounted_price'] and not combination_info['compare_list_price'] else 'd-none'}}"
|
||||
style="text-decoration: line-through; white-space: nowrap;"
|
||||
t-esc="combination_info['list_price']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"
|
||||
itemprop="listPrice"
|
||||
/>
|
||||
<t t-if="is_view_active('website_sale.tax_indication')" t-call="website_sale.tax_indication"/>
|
||||
<del t-if="product.compare_list_price">
|
||||
<span t-field="product.compare_list_price"
|
||||
groups="website_sale.group_product_price_comparison"
|
||||
t-options='{
|
||||
<del t-if="combination_info['compare_list_price'] and (combination_info['compare_list_price'] > combination_info['price'])">
|
||||
<span t-esc="combination_info['compare_list_price']"
|
||||
groups="website_sale.group_product_price_comparison"
|
||||
t-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": product.currency_id,
|
||||
"display_currency": website.currency_id,
|
||||
}'/>
|
||||
</del>
|
||||
</h3>
|
||||
@@ -1177,13 +1179,13 @@
|
||||
"display_currency": product.currency_id,
|
||||
}'/>
|
||||
<t t-if="is_view_active('website_sale.tax_indication')" t-call="website_sale.tax_indication"/>
|
||||
<del t-if="product.compare_list_price">
|
||||
<del t-if="combination_info['compare_list_price'] and (combination_info['compare_list_price'] > combination_info['price'])">
|
||||
<span t-field="product.compare_list_price"
|
||||
groups="website_sale.group_product_price_comparison"
|
||||
t-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": product.currency_id,
|
||||
}'/>
|
||||
groups="website_sale.group_product_price_comparison"
|
||||
t-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": website.currency_id,
|
||||
}'/>
|
||||
</del>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@@ -100,7 +100,8 @@
|
||||
</span>
|
||||
<span class="o_comparison_price" t-else="">
|
||||
<strong>Price:</strong>
|
||||
<del t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}"
|
||||
<del t-if="combination_info['compare_list_price'] and (combination_info['compare_list_price'] > combination_info['price'])" t-attf-class="text-danger mr8" style="white-space: nowrap;" t-esc="combination_info['compare_list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
|
||||
<del t-else="" t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}"
|
||||
style="white-space: nowrap;" t-esc="combination_info['list_price']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
|
||||
<span t-esc="combination_info['price']"
|
||||
@@ -158,7 +159,8 @@
|
||||
<h6>
|
||||
<a t-att-href="product.website_url"><t t-esc="combination_info['display_name']" /></a><br/>
|
||||
<div t-attf-class="{{'d-none' if combination_info['prevent_zero_price_sale'] else ''}}">
|
||||
<del t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="white-space: nowrap;" t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
|
||||
<del t-if="combination_info['compare_list_price'] and (combination_info['compare_list_price'] > combination_info['price'])" t-attf-class="text-danger mr8" style="white-space: nowrap;" t-esc="combination_info['compare_list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
|
||||
<del t-else="" t-attf-class="text-danger mr8 {{'' if combination_info['has_discounted_price'] else 'd-none'}}" style="white-space: nowrap;" t-esc="combination_info['list_price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
|
||||
<span t-esc="combination_info['price']" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
|
||||
</div>
|
||||
<div t-attf-class="{{'' if combination_info['prevent_zero_price_sale'] else 'd-none'}}" t-field="website.prevent_zero_price_sale_text"/>
|
||||
|
||||
Reference in New Issue
Block a user