Files
manufacture/mrp_bom_attribute_match/models/mrp_production.py
Ivàn Todorovich 5dde8e261e [IMP] mrp_bom_attribute_match: use constraints and computed fields
Instead of updates triggered by onchanges or writes, use constraints
to execute all checks, and a computed field for `match_on_attribute_ids`
2022-10-31 08:14:03 -03:00

18 lines
545 B
Python

from odoo import api, models
class MrpProduction(models.Model):
_inherit = "mrp.production"
def action_confirm(self):
res = super().action_confirm()
for bom_line in self.bom_id.bom_line_ids:
if bom_line.component_template_id:
# product_id was set in mrp.bom.explode for correct flow. Need to remove it.
bom_line.product_id = False
return res
@api.constrains("bom_id")
def _check_component_attributes(self):
self.bom_id._check_component_attributes()