From 5960b9cfccdb5704a9b2b4ce4fef47f4de11c073 Mon Sep 17 00:00:00 2001 From: techgrrow Date: Mon, 27 Jan 2025 15:25:15 +0100 Subject: [PATCH] [16.0][FIX] components quantities not updating On the production order, when changing the final product quantities to a number > 1, the components quantities did not update correctly. --- mrp_bom_line_formula_quantity/models/mrp_bom_line.py | 8 +++++++- .../tests/test_mrp_production.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mrp_bom_line_formula_quantity/models/mrp_bom_line.py b/mrp_bom_line_formula_quantity/models/mrp_bom_line.py index a32c10487ae..fa7bdc3bb4a 100644 --- a/mrp_bom_line_formula_quantity/models/mrp_bom_line.py +++ b/mrp_bom_line_formula_quantity/models/mrp_bom_line.py @@ -80,7 +80,13 @@ def _eval_quantity_formula( mode="exec", nocopy=True, ) - quantity = values.get("quantity", 0) + formula_quantity = values.get("quantity", 0) + product_uom_qty = values.get("product_uom_qty", 0) + quantity = ( + formula_quantity * product_uom_qty + if formula_quantity and product_uom_qty + else 0 + ) else: quantity = None return quantity diff --git a/mrp_bom_line_formula_quantity/tests/test_mrp_production.py b/mrp_bom_line_formula_quantity/tests/test_mrp_production.py index 13e438d8f69..3800855fb70 100644 --- a/mrp_bom_line_formula_quantity/tests/test_mrp_production.py +++ b/mrp_bom_line_formula_quantity/tests/test_mrp_production.py @@ -15,6 +15,7 @@ def test_line_quantity(self): formula_quantity = 10 bom = self.bom_1.copy() formula_bom_line = first(bom.bom_line_ids) + formula_bom_line.product_qty = 1 formula_bom_line["quantity_formula"] = "quantity = %s" % formula_quantity # pre-condition self.assertNotEqual(formula_bom_line.product_qty, formula_quantity) @@ -23,6 +24,7 @@ def test_line_quantity(self): order = self.env["mrp.production"].create( { "bom_id": bom.id, + "product_qty": bom.product_qty, } )