Skip to content
Snippets Groups Projects
Unverified Commit 1d6df46a authored by David Beal's avatar David Beal Committed by Martin Trigaux
Browse files

[IMP] product: add _variant_name() in product.attribute.value

To be possible to override the name_get of the variants
Closes #13053
parent 77aba59d
No related branches found
No related tags found
No related merge requests found
......@@ -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 = []
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment