From cb7a7deec5c1eda8c156e1b1f9e1f1e38d0abda2 Mon Sep 17 00:00:00 2001 From: jvm-odoo Date: Thu, 4 Jun 2020 11:46:35 +0000 Subject: [PATCH] [FIX] sale: fix no_variant price extra context propagation Issue - Install Sales - Enable discounts & pricelists - Create a product - 2 variants: - first with "create variant" set to Always - second set to Never - Create a SO - Pricelist setting "without_discount" - Add the product with product configurator The line price is not correct (only Always taken in account) Cause When the variant has Create Variant set to Never we pass the extra money in the context. When we have a pricelist with "without_discount" this context is not propagated correctly and it's lost Solution Pass the product directly if it's not empty which have the context set. OPW-2246102 closes odoo/odoo#53216 X-original-commit: 68628206c5883adc614045706fcc2ea085efd252 Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: Jason Van Malder (jvm) --- addons/sale/models/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index cd6abfd9f5e..877bd7602b3 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -1544,7 +1544,7 @@ class SaleOrderLine(models.Model): return product.with_context(pricelist=self.order_id.pricelist_id.id).price product_context = dict(self.env.context, partner_id=self.order_id.partner_id.id, date=self.order_id.date_order, uom=self.product_uom.id) - final_price, rule_id = self.order_id.pricelist_id.with_context(product_context).get_product_price_rule(self.product_id, self.product_uom_qty or 1.0, self.order_id.partner_id) + final_price, rule_id = self.order_id.pricelist_id.with_context(product_context).get_product_price_rule(product or self.product_id, self.product_uom_qty or 1.0, self.order_id.partner_id) base_price, currency = self.with_context(product_context)._get_real_price_currency(product, rule_id, self.product_uom_qty, self.product_uom, self.order_id.pricelist_id.id) if currency != self.order_id.pricelist_id.currency_id: base_price = currency._convert(