From ccd66d3e18ebffe265c2e3680ec85dee2838f828 Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Thu, 17 Nov 2022 10:36:21 +0000 Subject: [PATCH] [FIX] mrp: clear component if the BoM change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Create a storable product ”P1” with 2 BoM: - BoM 1: Type: manufacture Component: C1 - BoM 2: Type: manufacture Component: C2 - Create a MO: - Add the product “P1” - The BoM 1 is automatically set and the component “C1” is added - Save the MO - Edit The MO: - set the BoM 2 instead of BoM 1 Problem: The component C2 is added, but the component “C1” linked to BoM 1 is not deleted To delete the existing lines, we check if the product has changed, but we do not check if the BoM has changed: https://github.com/odoo/odoo/blob/16.0/addons/mrp/models/mrp_production.py#L694 Solution: clear “move_raws” if BoM change. No need to check if the product has changed to clear component,because if the product changes, the bom changes too opw-3069283 closes odoo/odoo#105983 X-original-commit: 916449eb382715f341b05666cfec336e30c5db36 Signed-off-by: William Henrotin (whe) --- addons/mrp/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 2297acfb82e..5de10fb8b43 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -691,7 +691,7 @@ class MrpProduction(models.Model): list_move_raw = [Command.link(move.id) for move in production.move_raw_ids.filtered(lambda m: not m.bom_line_id)] if not production.bom_id and not production._origin.product_id: production.move_raw_ids = list_move_raw - if production.product_id != production._origin.product_id: + if production.bom_id != production._origin.bom_id: production.move_raw_ids = [Command.clear()] if production.bom_id and production.product_id and production.product_qty > 0: # keep manual entries