summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2021-03-25 08:21:48 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2021-03-29 15:31:32 +0000
commite16fc2b095c67fca7f1ad7ef8d5645c690c40280 (patch)
tree5fa92f5a6e82517060ddc25d68a07074b2210300
parentbfbd8485259d6f27241434d33b16daba57be7a50 (diff)
[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#68485 X-original-commit: ab24134abb81399acd6ee49c4553aa0930384e37 Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com> Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
-rw-r--r--addons/sale_management/models/sale_order.py12
1 files 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