Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] mrp_production_stencil_product: Copy Stencil Products when dupl… #503

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion mrp_production_stencil_product/models/mrp_bom.py
Original file line number Diff line number Diff line change
@@ -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