Skip to content
Snippets Groups Projects
Commit a8a98a61 authored by William Henrotin's avatar William Henrotin
Browse files

[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
parent d57fce20
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment