Hi,
how to order by ASC OR DESC a field in a view form in openerp?
Thanks!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
how to order by ASC OR DESC a field in a view form in openerp?
Thanks!
_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?
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!
you can add to your model class
_order = 'FIELD_NAME asc'
or
_order = 'FIELD_NAME desc'
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up