[FIX] website_sale: check settings for price comparison
**Current behavior:**
Enabling the 'Comparison Price' setting and filling out the
field will result in this strikethrough price appearing even
after disabling the setting.
**Expected behavior:**
The strikethrough comparison price will only appear when the
corresponding setting is enabled in the database settings.
**Steps to reproduce:**
1. Enable the 'Comparison Price' setting in website settings
2. Select a product on the 'Shop' page of the website and edit
it so it has a comparison price != to its regular one
3. Save product changes, go back to the db settings and disable
the 'Comparison Price' setting
4. Go back to the website 'Shop' page and observe that the
strikethrough comparison price is still displayed
**Cause of the issue:**
In the product.template model in website_sale, the price values
are modified to those informed by the compare_list_price value
independent of the current value of the corresponding database
setting. It only checks if there is non-False value in the
field.
**Fix:**
Check if the user belongs to the group corresponding to this db
settings prior to modifying the product template to display the
strikethrough compare price.
opw-3705079
closes odoo/odoo#154573
X-original-commit: 0d76bdb23d26f777587c9c30d5479fdf3c694937
Signed-off-by: Vincent Ethan <etvi@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
@@ -261,6 +261,7 @@ class ProductTemplate(models.Model):
|
||||
|
||||
sales_prices = pricelist._get_products_price(self, 1.0)
|
||||
show_discount = pricelist and pricelist.discount_policy == 'without_discount'
|
||||
show_strike_price = self.env.user.has_group('website_sale.group_product_price_comparison')
|
||||
|
||||
base_sales_prices = self._price_compute('list_price', currency=currency)
|
||||
website = self.env['website'].get_current_website()
|
||||
@@ -279,7 +280,7 @@ class ProductTemplate(models.Model):
|
||||
base_price = None
|
||||
price_list_contains_template = currency.compare_amounts(price_reduce, base_sales_prices[template.id]) != 0
|
||||
|
||||
if template.compare_list_price:
|
||||
if template.compare_list_price and show_strike_price:
|
||||
# The base_price becomes the compare list price and the price_reduce becomes the price
|
||||
base_price = template.compare_list_price
|
||||
if not price_list_contains_template:
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.fields import Command
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingHttpCommon
|
||||
|
||||
|
||||
@@ -112,4 +116,9 @@ class WebsiteSaleShopPriceListCompareListPriceDispayTests(AccountTestInvoicingHt
|
||||
})
|
||||
|
||||
def test_compare_list_price_price_list_display(self):
|
||||
self.env.user.write({
|
||||
'groups_id': [Command.link(
|
||||
self.env.ref('website_sale.group_product_price_comparison').id
|
||||
)],
|
||||
})
|
||||
self.start_tour("/", 'compare_list_price_price_list_display', login=self.env.user.login)
|
||||
|
||||
Reference in New Issue
Block a user