Odoo Help


Can you set order_by in a xml tree view?

on 7/10/14, 1:45 PM 2,941 views

I was wondering if there is a way to set the order_by for a specific tree view in the xml code.  Is there a way to do this?

Géry Debongnie (ged)
On 12/22/14, 10:37 AM

There is a default_order attribute


On 12/19/14, 2:43 PM

You can do this in your module's action code (or inherit an already existing action). 

Set it in the context with 'order'.  To order it by the Status field for instance (which is 'state' in the database):

 <record id="action_unique_identifier" model="ir.actions.act_window">
             <!-- a bunch of fields -->
            <field name="context">{'order': 'state'}</field>


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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

2 follower(s)


Asked: 7/10/14, 1:45 PM
Seen: 2941 times
Last updated: 3/16/15, 8:10 AM