Odoo Help


Change default sort order

Michael St-Georges
on 9/4/14, 1:06 PM 13,238 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)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

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

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.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
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

Forsberg Services Ltd, Raphael
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.

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: 13238 times
Last updated: 12/2/15, 3:31 PM