Skip to Content
Menu
This question has been flagged
2 Replies
49918 Views

Hi, 

 

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

Thanks!

Avatar
Discard
Best Answer

_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"

 

 

Avatar
Discard
Author

Will it automatically be ordered in the form view?

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

i dont need any order. can we workout like that?

Thanks this answer helped me!

i did one field, but it requires 2 '_orders'

Example:

_order = "appointment_date"

_order = "appointment_date desc"

here,

1. appointment_date is my date field.

2. asc or desc, caps or small doesn't really matter.

Thanks!

Best Answer

you can add to your model class

    _order = 'FIELD_NAME asc'

or

    _order = 'FIELD_NAME desc'

Avatar
Discard