From 0e562c8a7d825cd6c162093422fb023c643ec3df Mon Sep 17 00:00:00 2001 From: David Vidal Date: Sat, 30 Sep 2017 12:11:54 +0200 Subject: [PATCH] [FIX] website_sale: Avoid map tax for every company When a product has multiple company taxes and b2c prices is enabled, price is not computed properly and adds to the base price every company tax present. This patch filters the company set on the company so taxes are computed just for that company. This commit closes #18840 Depend of the previous commit which add right to public user. #18881 --- addons/website_sale/models/product.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index c21d04865ea..45154eae1ef 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -183,7 +183,9 @@ class Product(models.Model): def _website_price(self): qty = self._context.get('quantity', 1.0) partner = self.env.user.partner_id - pricelist = self.env['website'].get_current_website().get_current_pricelist() + current_website = self.env['website'].get_current_website() + pricelist = current_website.get_current_pricelist() + company_id = current_website.company_id context = dict(self._context, pricelist=pricelist.id, partner=partner) self2 = self.with_context(context) if self._context != context else self @@ -191,7 +193,7 @@ class Product(models.Model): ret = self.env.user.has_group('sale.group_show_price_subtotal') and 'total_excluded' or 'total_included' for p, p2 in pycompat.izip(self, self2): - taxes = partner.property_account_position_id.map_tax(p.taxes_id) + taxes = partner.property_account_position_id.map_tax(p.taxes_id.filtered(lambda x: x.company_id == company_id)) p.website_price = taxes.compute_all(p2.price, pricelist.currency_id, quantity=qty, product=p2, partner=partner)[ret] p.website_public_price = taxes.compute_all(p2.lst_price, quantity=qty, product=p2, partner=partner)[ret] @@ -200,6 +202,7 @@ class Product(models.Model): self.ensure_one() return self.product_tmpl_id.website_publish_button() + class ProductAttribute(models.Model): _inherit = "product.attribute"