Skip to main content
Aleksandr Ovcharenko
New Member
September 22, 2026
Question

How to sort variants programmatically?

It seems there is no plugin API feature for changing the order of component variants. There is some plugin that does it, but I was not able to find the trick how it is done. Can someone help with this? Manual sorting of 100+ options is a disaster. 

2 replies

JesseHilton
New Participant
September 22, 2026

If you mean sorting product variants in Odoo, you can sort them using a field such as the variant name, attribute value, or sequence. For custom sorting, you can usually apply an order in the model search or override the relevant method.

For example, you can sort records by name with:

variants = self.env['product.product'].search([], order='name asc')

You can change name asc to another field and use desc for descending order.

If you share which Odoo version and which variant order you want, it would be easier to suggest the exact approach.

Jaycee Lewis
Figmate
Figmate
September 22, 2026

Hey ​@Aleksandr Ovcharenko 👋 Can you share a link to the plugin? Happy to see what we find in the public docs. — Jaycee