[FIX] website_sale: no tax included in snipets products

Steps to reproduce:
- Take a product sold on the e-commerce and add taxes
- In the Website settings chose the product prices to be
 shown tax-included
- Add the snippet "Products"

Problem:
The price shown on the snippet is tax-excluded while the
price shown on the product page is tax-included. The
price on the snippet should also be tax-included.

Explanation
Bug introduced by commit 9e99a9df46
using the _get_contextual_price ignored the option where the taxes
needed to be computed. To solve the issue we create a new function
that calls _get_contextual_price but also add the taxes if
necessary.

opw-2894461

closes odoo/odoo#96285

X-original-commit: a029aea6e332eca8abbc0591f8885afaaa223e75
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
mafo-odoo
2022-07-19 21:22:01 +02:00
parent f3f66d33db
commit cf12a41b94
2 changed files with 9 additions and 1 deletions
@@ -287,7 +287,7 @@
</template>
<template id="price_dynamic_filter_template_product_product" name="Dynamic Product Filter Price">
<t t-set="record_price" t-value="record._get_contextual_price()"/>
<t t-set="record_price" t-value="record._get_contextual_price_tax_selection()"/>
<t t-if="not website.prevent_zero_price_sale or record_price">
<span t-esc="record_price" class="fw-bold"
t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
@@ -94,3 +94,11 @@ class Product(models.Model):
def _is_add_to_cart_allowed(self):
self.ensure_one()
return self.user_has_groups('base.group_system') or (self.sale_ok and self.website_published)
def _get_contextual_price_tax_selection(self):
self.ensure_one()
price = self._get_contextual_price()
line_tax_type = self.env['ir.config_parameter'].sudo().get_param('account.show_line_subtotals_tax_selection')
if line_tax_type == "tax_included" and self.taxes_id:
price = self.taxes_id.compute_all(price, product=self, partner=self.env['res.partner'])['total_included']
return price