Odoo Help

Welcome!

This community 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.

1

Order by ASC or DESC in openerp

By
Nanie BE
on 11/5/14, 2:40 AM 8,326 views

Hi, 

 

how to order by ASC OR DESC  a field in a view form in openerp?

Thanks!

2

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 11/5/14, 2:58 AM

_order: (https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/object_attributes/)
Name of the fields used to sort the results of the search and read methods.

Default value: 'id'.

Examples:
_order = "name"
_order = "date_order desc"

Also, it can be ordered with multiple fields also.
_order = "name, date_order desc"

 

 

Will it automatically be ordered in the form view?

Nanie BE
on 11/5/14, 3:34 AM

yes. when Odoo tries to load the record, it will check whether the table contain any _order available with it. If value is set, then records are loaded sequentially according to your field set at _order

Atchuthan - Technical Consultant, Sodexis Inc
on 11/5/14, 4:35 AM
2
Mohamed Magdy
On 11/5/14, 2:52 AM

you can add to your model class

    _order = 'FIELD_NAME asc'

or

    _order = 'FIELD_NAME desc'

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/5/14, 2:40 AM
Seen: 8326 times
Last updated: 6/1/15, 2:11 PM