Odoo Help


Change default sort order

Michael St-Georges
on 9/4/14, 1:06 PM 10,147 views



Is there a way to change the default sorting column for a treeview (sales.order specifically)? I have a custom field I have set up and would like the sorting to default to this column.


Thanks all

Cyril Gaspard (GEM)
On 9/4/14, 5:25 PM


in your class inherited of you module,

add :

class NameClass(....):

    _inherit = "name.class"

    _order = "custom_field_name, other_field ..." (you can add option asc or desc too)


Thanks for the prompt answer. I kind of hoped there was a GUI way of doing things since this is for just that one very very specific install, but I guess there isn't.

Michael St-Georges
on 9/4/14, 6:28 PM

How can I give spesific order to tree view?? In your answer we must inherit class. Can we do it?

Andre Leander
on 11/19/14, 2:03 AM

see https://www.odoo.com/forum/help-1/question/order-one2many-lines-29222#answer-75504

Cyril Gaspard (GEM)
on 2/20/15, 7:38 PM
Ray Carnes
On 10/31/15, 12:58 PM


As of Odoo 8 you can simply add a default_order attribute in the view definition, to override the default ordering of the model. The syntax for this attribute is the same as the `_order` attribute of the model in Python.


<tree default_order='date_expected, picking_id, sequence'>

I tried this under the edit tree view - Manufacturing Orders (Edit Tree View (Developers Mode)) by adding the following line It now reads: It comes up with a ValidateError Field(s) `arch` failed against a constraint: Invalid view definition

on 12/3/15, 8:29 AM

Post a new question and expand 'I tried this' into steps with screenshots, so we can understand what you did and where you went wrong.

Bista Solutions US, Ray Carnes
on 12/3/15, 2:04 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/4/14, 1:06 PM
Seen: 10147 times
Last updated: 12/2/15, 3:31 PM