This question has been flagged
2 Replies
8085 Views

When I input attribute values manually in the product template form using the many2many_tags widget provided, the attribute values get sorted  when saving the form. But at the product attribute line I want them to keep the  same order as I have entered them.

How can I achieve that?



Avatar
Discard
Best Answer

In default, the attribute and the attribute values are sorting according to the sequence. ie,

_order = 'sequence'

so to make it as per the entered value, either you have to override the model and add a new _order 

to inherit model you have to just add

class ProductAttributevalue(models.Model):
_name = "product.attribute.value"
_order = 'id asc'


But I am not sure whether we can change the order according to the selection. I tried but I can't.


Avatar
Discard
Best Answer

Hi Ermin,

For sorting product attribute line you can add something like this in one2many tree view
 <tree default_order="attribute_id desc">

Avatar
Discard