Odoo Help


[SOLVED] OpenERP 7: Tree view - Order by date of creation and not by name

on 5/16/15, 11:09 AM 4,984 views

Hi all,

I would like to know if it is possible, to order the customers by creation date and not by name.

I would like to do it on the "Tree View" in the sale part.

For OpenERP 8 , I can  override the python default order in the tree view

<tree default_order='create_date'> 


But it doesn't work for OpenERP 7. 

Are they another possibility?

Someone has an idea please?

Thank you,





| 6 5 7
Tbilisi, Georgia
On 5/18/15, 6:57 AM

in v7 try to add create_date field to the corresponding model:

_columns = {
    'create_date': fields.datetime('Create Date'),
_order = "create_date" # To order using create_date

you have not to manage 'create_date' field in any way, it'll be managed automatically. just add it.

then update module and try again. hope it'll help.

Hi Temur, Thank you for your answer. However, even with this, my Tree order automatically by name and not by create_date. So after I can manually order it with the view interface but I would like automatically by create_date and not by name. Btw why it is automatically by name? Thank you, Selverine

on 5/24/15, 4:55 AM

additionally to add 'create_date', use _order in a model, as suggested @Ray:

_order = "create_date"
then it'll be ordered automatically.
also it may be good idea to add readonly=True to create_date field, as it's special field and users do not have to edit it, it's managed by server.
on 5/25/15, 3:42 AM

Hi Temur. It is still not working...it is still ordering by name. Maybe in another part some function override my order no?

on 5/30/15, 5:48 AM

Hi Selverine. yes, that's possible if you're adding changes in a original code, then it may be overriden by module inheriting from module you're changing code in. You should do the stuff (add "create_date" and "_order") in your own custom module, NOT in a base code of Odoo modules(in general it's a bed idea to change anything in original code of base modules). Inherit corresponding model in the custom module and to stuff there, then add model's original module to dependency list of your module ("depends" - in __openerp__.py) and your module will override behavior of original model. if you find that it's overriden in another module, then add that module to "depends" list to overcome it's definitions.

on 6/1/15, 5:50 AM

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 5/24/15, 12:00 PM

The way to define the sort order of a model in Python is with:

_order = "first_field, optional_second_field"

If there is no order specified, the default is ID.

Check the documentation at https://www.odoo.com/documentation/8.0/reference/orm.html

Hi Ray. Thank you for your help. I did this inside my class class res_partner(osv.osv, format_address) ( res_partner.py inside the folder /base/res). However it is still not working and it ordered by name and not my create_date. Maybe somewhere a class override my order no? Thank you. Selverine

on 5/30/15, 5:46 AM

Selverine, you should not be changing code Odoo code (in the base/res folder). You should make your own module. You can see which modules could be changing the defaults for res.partner by looking in Settings --> Technical --> Database Structure --> Models. Open the res.partner module and look at the 'In Modules' field - this shows you a list of all modules that are contributing to the definition of the model, and that could be changing the default sort order.

Ray Carnes
on 6/2/15, 8:24 AM
On 6/3/15, 10:35 AM

It is working :-).

Thank you both for your help.

So it was this. One module override the order.

After override it by a new class directly in the sale module it is working perfectly.

Thank you!!

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: 5/16/15, 11:09 AM
Seen: 4984 times
Last updated: 6/17/15, 8:48 AM