From 2387a045aba939ffd8aab722f059658acfa20ba9 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Thu, 25 Mar 2021 08:21:48 +0000 Subject: [PATCH] [FIX] sale_management: fix pricelist computation for optional products 1. Have a product with cost A 2. Have a pricelist which modify the price of the product to B based on the quantity 3. Create a sale order with the pricelist. Under the "Optional Products" tab add the product and match the pricelist requirements No price modification will occur, because there is no reaction to the quantity change opw-2480696 closes odoo/odoo#68494 X-original-commit: ab24134abb81399acd6ee49c4553aa0930384e37 Signed-off-by: agr-odoo Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/sale_management/models/sale_order.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/sale_management/models/sale_order.py b/addons/sale_management/models/sale_order.py index 4ed4ebd69d4..165d5acf59b 100644 --- a/addons/sale_management/models/sale_order.py +++ b/addons/sale_management/models/sale_order.py @@ -220,11 +220,19 @@ class SaleOrderOption(models.Model): return [('line_id', '=', False)] return [('line_id', '!=', False)] - @api.onchange('product_id', 'uom_id') + @api.onchange('product_id', 'uom_id', 'quantity') def _onchange_product_id(self): if not self.product_id: return - product = self.product_id.with_context(lang=self.order_id.partner_id.lang) + product = self.product_id.with_context( + lang=self.order_id.partner_id.lang, + partner=self.order_id.partner_id, + quantity=self.quantity, + date=self.order_id.date_order, + pricelist=self.order_id.pricelist_id.id, + uom=self.uom_id.id, + fiscal_position=self.env.context.get('fiscal_position') + ) self.name = product.get_product_multiline_description_sale() self.uom_id = self.uom_id or product.uom_id # To compute the discount a so line is created in cache