Skip to content

Commit

Permalink
[IMP] mrp_production_stencil_product: Copy Stencil Products when dupl…
Browse files Browse the repository at this point in the history
…icate BoM.
  • Loading branch information
alfredoavanzosc authored and anajuaristi committed Jan 28, 2025
1 parent b3a5f68 commit 51bfc28
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion mrp_production_stencil_product/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,32 @@ class MrpBom(models.Model):
string="Stencil products",
comodel_name="mrp.bom.stencil.product",
inverse_name="bom_id",
copy=False,
copy=True,
)

def copy(self, default=None):
default = default or {}
default_stencil_products = [
(
0,
0,
{
"product_id": (
stencil.product_id.id if stencil.product_id else False
),
"location_id": (
stencil.location_id.id if stencil.location_id else False
),
"product_uom_id": (
stencil.product_uom_id.id if stencil.product_uom_id else False
),
"product_uom_qty": (
stencil.product_uom_qty if stencil.product_uom_qty else 0
),
},
)
for stencil in self.stencil_product_ids
]
default["stencil_product_ids"] = default_stencil_products
new_record = super().copy(default)
return new_record

0 comments on commit 51bfc28

Please sign in to comment.