Skip to content

Commit 51bfc28

Browse files
alfredoavanzoscanajuaristi
authored andcommitted
[IMP] mrp_production_stencil_product: Copy Stencil Products when duplicate BoM.
1 parent b3a5f68 commit 51bfc28

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

mrp_production_stencil_product/models/mrp_bom.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,32 @@ class MrpBom(models.Model):
1010
string="Stencil products",
1111
comodel_name="mrp.bom.stencil.product",
1212
inverse_name="bom_id",
13-
copy=False,
13+
copy=True,
1414
)
15+
16+
def copy(self, default=None):
17+
default = default or {}
18+
default_stencil_products = [
19+
(
20+
0,
21+
0,
22+
{
23+
"product_id": (
24+
stencil.product_id.id if stencil.product_id else False
25+
),
26+
"location_id": (
27+
stencil.location_id.id if stencil.location_id else False
28+
),
29+
"product_uom_id": (
30+
stencil.product_uom_id.id if stencil.product_uom_id else False
31+
),
32+
"product_uom_qty": (
33+
stencil.product_uom_qty if stencil.product_uom_qty else 0
34+
),
35+
},
36+
)
37+
for stencil in self.stencil_product_ids
38+
]
39+
default["stencil_product_ids"] = default_stencil_products
40+
new_record = super().copy(default)
41+
return new_record

0 commit comments

Comments
 (0)