diff --git a/mrp_bom_attribute_match/__manifest__.py b/mrp_bom_attribute_match/__manifest__.py index e689d9e3f..c467414c0 100644 --- a/mrp_bom_attribute_match/__manifest__.py +++ b/mrp_bom_attribute_match/__manifest__.py @@ -5,6 +5,7 @@ "author": "Ilyas, Ooops, Odoo Community Association (OCA)", "summary": "Dynamic BOM component based on product attribute", "depends": ["mrp"], + "maintainers": ["ilyasProgrammer", "ivantodorovich"], "license": "AGPL-3", "website": "https://github.com/OCA/manufacture", "data": [ diff --git a/mrp_bom_attribute_match/models/mrp_bom.py b/mrp_bom_attribute_match/models/mrp_bom.py index ca7457bf4..590dc1d59 100644 --- a/mrp_bom_attribute_match/models/mrp_bom.py +++ b/mrp_bom_attribute_match/models/mrp_bom.py @@ -15,7 +15,9 @@ class MrpBomLine(models.Model): "product.product", help="Technical field to store previous value of product_id" ) component_template_id = fields.Many2one( - "product.template", "Component (product template)" + "product.template", + "Component (product template)", + domain="[('id', '!=', parent_product_tmpl_id)]", ) match_on_attribute_ids = fields.Many2many( "product.attribute", @@ -29,6 +31,18 @@ class MrpBomLine(models.Model): compute="_compute_product_uom_category_id", ) + @api.constrains("component_template_id") + def _check_component_template_recursion(self): + for line in self: + if line.component_template_id == line.parent_product_tmpl_id: + raise ValidationError( + _( + "Component template must be different from BOM " + "product template. Please check BOM: %s BOM Line: %s" + ) + % (line, line.bom_id) + ) + @api.depends("product_id", "component_template_id") def _compute_product_uom_category_id(self): """Compute the product_uom_category_id field. diff --git a/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst b/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst index 1a74944ba..56e16e01f 100644 --- a/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst +++ b/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst @@ -1,6 +1,6 @@ * Ooops404 - * Ilyas + * Ilyas * `Camptocamp `_