From a8a98a614ce26197524ee2c1072c98e72d094f12 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Wed, 24 Jun 2020 08:05:45 +0000 Subject: [PATCH] [FIX] mrp: bom with operation duplication Duplicate a BoM with operations and some BoM line consume in specific operation. The operations are well duplicated but the 'consume in operation' field still point to the original BoM's operations. This commit search for the operation to replace based on the name and the workcenter_id. Task : 2278147 X-original-commit: 4c6d445dfd561a236b1b171ccbcc2ff2b6236640 --- addons/mrp/models/mrp_bom.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index 7a154b16d0f..5256e23a0fd 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -122,6 +122,14 @@ class MrpBom(models.Model): for line in self.bom_line_ids: line.bom_product_template_attribute_value_ids = False + def copy(self, default=None): + res = super().copy(default) + for bom_line in res.bom_line_ids: + if bom_line.operation_id: + operation = res.operation_ids.filtered(lambda op: op.name == bom_line.operation_id.name and op.workcenter_id == bom_line.operation_id.workcenter_id) + bom_line.operation_id = operation + return res + @api.model def name_create(self, name): # prevent to use string as product_tmpl_id