[FIX] product: Issues with product configurator with single attribute values
When creating several attribute lines for the same attribute, the function _update_product_template_attribute_values in model 'product.template.attribute.line' only kept the product.template.attribute.value records of the last created line. So it generated issues with the product configurator because no value was founded for certain attribute line in function _get_possible_combinations defined in model 'product.template'. Now it's forbidden to create several attribute lines for the same attribute. opw:1950786 closes odoo/odoo#32086 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user