diff --git a/addons/product/i18n/product.pot b/addons/product/i18n/product.pot index f7d45412de6..f1c01a7cb78 100644 --- a/addons/product/i18n/product.pot +++ b/addons/product/i18n/product.pot @@ -2424,6 +2424,12 @@ msgstr "" msgid "You cannot define the decimal precision of 'Account' as greater than the rounding factor of the company's main currency" msgstr "" +#. module: product +#: code:addons/product/models/product_template.py:332 +#, python-format +msgid "You cannot define two attribute lines for the same attribute." +msgstr "" + #. module: product #: code:addons/product/models/product_attribute.py:79 #, python-format diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index f20e3da3dc5..afe17aaadad 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -326,6 +326,12 @@ class ProductTemplate(models.Model): raise ValidationError(_('The default Unit of Measure and the purchase Unit of Measure must be in the same category.')) return True + @api.constrains('attribute_line_ids') + def _check_attribute_line(self): + if any(len(template.attribute_line_ids) != len(template.attribute_line_ids.mapped('attribute_id')) for template in self): + raise ValidationError(_('You cannot define two attribute lines for the same attribute.')) + return True + @api.onchange('uom_id') def _onchange_uom_id(self): if self.uom_id: