diff --git a/addons/website_sale/models/product_template.py b/addons/website_sale/models/product_template.py index 7b140255622..e196dc210d9 100644 --- a/addons/website_sale/models/product_template.py +++ b/addons/website_sale/models/product_template.py @@ -185,12 +185,7 @@ class ProductTemplate(models.Model): product_taxes = template.sudo().taxes_id.filtered(lambda t: t.company_id == t.env.company) taxes = fiscal_position.map_tax(product_taxes) - - price_reduce = self.env['account.tax']._fix_tax_included_price_company( - price_reduce, product_taxes, taxes, self.env.company) - tax_display = 'total_excluded' if self.env.company.show_line_subtotals_tax_selection == 'tax_excluded' else 'total_included' - price_reduce = taxes.compute_all(price_reduce, currency, 1, template, partner_sudo)[tax_display] template_price_vals = { 'price_reduce': price_reduce @@ -229,6 +224,8 @@ class ProductTemplate(models.Model): fields.Datetime.now(), round=False ) + template_price_vals['price_reduce'] = self.env['account.tax']._fix_tax_included_price_company(template_price_vals['price_reduce'], product_taxes, taxes, self.env.company) + template_price_vals['price_reduce'] = taxes.compute_all(template_price_vals['price_reduce'], pricelist.currency_id, 1, template, partner_sudo)[tax_display] res[template.id] = template_price_vals diff --git a/addons/website_sale/tests/test_website_sale_pricelist.py b/addons/website_sale/tests/test_website_sale_pricelist.py index 7cb12033b69..9a95da7e483 100644 --- a/addons/website_sale/tests/test_website_sale_pricelist.py +++ b/addons/website_sale/tests/test_website_sale_pricelist.py @@ -277,6 +277,25 @@ class TestWebsitePriceList(TransactionCase): self.assertEqual(sol.discount, 0, 'Pricelist price should be applied') self.assertEqual(sol.price_total, 60.0) + def test_get_right_discount(self): + """ Test that `_get_sales_prices` from `product_template` + returns a dict with just `price_reduce` (no discount) as key + when the product is tax included. + """ + tax = self.env['account.tax'].create({ + 'name': "Tax 10", + 'amount': 10, + }) + + product = self.env['product.template'].create({ + 'name': 'Event Product', + 'list_price': 10.0, + 'taxes_id': tax, + }) + + prices = product._get_sales_prices(self.list_christmas) + self.assertFalse('base_price' in prices[product.id]) + def simulate_frontend_context(self, website_id=1): # Mock this method will be enough to simulate frontend context in most methods