Odoo Help


11 Answers

Cyril Gaspard (GEM) France

--Cyril Gaspard (GEM)--
| 6 6 10
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Rank #1 on first OpenERP forum

OpenERP award "Top Contributor" 2011, for my actions on forum

Odoo forum moderator

Cyril Gaspard (GEM) France
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)


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

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.

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

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

Cyril Gaspard (GEM) France
2/20/15, 7:38 PM

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


Ray Carnes United States

--Ray Carnes--
| 10 7 11
Greater Los Angeles, United States
--Ray Carnes--

Business Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0, 11.0 and 12.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes United States
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'>
Forsberg Services Ltd, Raphael United Kingdom
12/3/15, 8:29 AM

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

Ray Carnes United States
12/3/15, 2:04 PM

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.

Oocademy, Yenthe Van Ginneken Belgium
7/18/18, 3:24 AM

Working for four years with Odoo now and I never knew this. Thanks Ray, great tip! Upvoted.

Vysakh Bt India
6/26/19, 3:48 AM

@Ray : I tried this method and it is working perfectly for ascending order.Can you please tell how to do it in descinding order ?Thanks

Vysakh Bt India
6/26/19, 3:51 AM

<tree default_order='date desc'> Does the trick for me.(For descinding order)

Darshan Patel India
10/13/19, 11:29 AM

Instead of changing from the _order attribute from Python File.

You can just change the default_order attribute of Tree View (This way you can have different order by based on each tree view for that specific model)

<tree default_order="name">

- And can inherit base view with following syntax (Descending example)

<xpath expr="//tree" position="attributes">
        <attribute name="default_order">name desc</attribute>

Ask a Question
Keep Informed
1 follower(s)
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