[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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user