From bdd8c59b8adbfd35f107f2b5d367698bca734c90 Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Tue, 12 Mar 2024 10:46:19 +0100 Subject: [PATCH] [FIX] website_sale: fix cart price discount calculation To reproduce: ============= - In the Settings: Product prices displayed on the website set as "Tax Included". - Created a test product (for example price 100$ tax 15%). - Created a price list with fixed price 15$ for all products - Pricelist configured as "Selectable" and set to "Show public price & discount to the customer". - on the product shop page, the price is 17.25$ instead of 115$ (which is the correct). - add product to cart and check the cart price, it's 17.25$ instead of 100$. Problem: ======== The undiscounted price displayed on the cart didn't consider the website configuration (tax excluded/included). Solution: ========= Consider the website configuration to show the expected undiscounted amount. opw-3771242 closes odoo/odoo#157357 Signed-off-by: Victor Feyens (vfe) Co-authored-by: Victor Feyens --- addons/website_sale/models/sale_order_line.py | 8 ++++++++ addons/website_sale/views/templates.xml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/models/sale_order_line.py b/addons/website_sale/models/sale_order_line.py index ff6db4e2521..98c4152ea85 100644 --- a/addons/website_sale/models/sale_order_line.py +++ b/addons/website_sale/models/sale_order_line.py @@ -70,6 +70,14 @@ class SaleOrderLine(models.Model): self.shop_warning = '' return warn + def _get_displayed_unit_price(self): + show_tax = self.order_id.website_id.show_line_subtotals_tax_selection + tax_display = 'total_excluded' if show_tax == 'tax_excluded' else 'total_included' + + return self.tax_id.compute_all( + self.price_unit, self.currency_id, 1, self.product_id, self.order_partner_id, + )[tax_display] + def _show_in_cart(self): self.ensure_one() # Exclude delivery line from showing up in the cart diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index d50ced9bd8e..5f94c8a2c25 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -1605,7 +1605,7 @@