[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) <vfe@odoo.com>
Co-authored-by: Victor Feyens <vfe@odoo.com>
This commit is contained in:
Abdelouahab (abla)
2024-03-12 16:59:07 +00:00
committed by Victor Feyens
co-authored by Victor Feyens
parent cff93694a7
commit bdd8c59b8a
2 changed files with 9 additions and 1 deletions
@@ -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
+1 -1
View File
@@ -1605,7 +1605,7 @@
<t t-if="line.discount">
<del t-attf-class="#{'text-danger mr8'}"
style="white-space: nowrap;"
t-out="line.price_unit * line.product_uom_qty"
t-out="line._get_displayed_unit_price() * line.product_uom_qty"
t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
</t>
<t t-if="website.show_line_subtotals_tax_selection == 'tax_excluded'"