diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 0416c68598b9fae901a8b41a8e6e9cf30f6605bc..10ec0e20208fa199ae027b8fcbccac84073f5b1c 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -387,7 +387,7 @@ class ProductProduct(models.Model): for product in self.sudo(): # display only the attributes with multiple possible values on the template variable_attributes = product.attribute_line_ids.filtered(lambda l: len(l.value_ids) > 1).mapped('attribute_id') - variant = ", ".join([v.name for v in product.attribute_value_ids if v.attribute_id in variable_attributes]) + variant = product.attribute_value_ids._variant_name(variable_attributes) name = variant and "%s (%s)" % (product.name, variant) or product.name sellers = [] diff --git a/addons/product/models/product_attribute.py b/addons/product/models/product_attribute.py index a0cdb0e9805e949a739b5293fe38334c0b0e5fd4..d90e070c05e1e04cf9dfef72a0e7461421e40e25 100644 --- a/addons/product/models/product_attribute.py +++ b/addons/product/models/product_attribute.py @@ -74,6 +74,10 @@ class ProductAttributevalue(models.Model): raise UserError(_('The operation cannot be completed:\nYou are trying to delete an attribute value with a reference on a product variant.')) return super(ProductAttributevalue, self).unlink() + @api.multi + def _variant_name(self, variable_attributes): + return ", ".join([v.name for v in self if v.attribute_id in variable_attributes]) + class ProductAttributePrice(models.Model): _name = "product.attribute.price"