-
- Downloads
[IMP] base: support ordering on custom models
Up until now, it was impossible to specify the default ordering
on models created manually.
This could somewhat be bypassed by specifying the ordering of records on
views themselves, but this has one main drawback: when using a
relational field that targets a custom model as a group-by key, the
ordering defaulted to the id of the custom record. For example, if I
create a custom field on partners that points to a custom model
'x_grade' on which an 'x_sequence' field exists, I could order my grade
in their own list view according to their sequence, but any read on
partners grouped by this 'x_grade_id' field would order the returned
groups by id while I would prefer to have them ordered according to the
'x_sequence' field.
This commit introduces a new field 'default_order' on the ir.model model
that can store this default ordering clause (as an SQL expression).
Co-Authored-By:
Raphaël Collet <rco@odoo.com>
Showing
- odoo/addons/base/models/ir_model.py 30 additions, 2 deletionsodoo/addons/base/models/ir_model.py
- odoo/addons/base/tests/test_ir_model.py 104 additions, 1 deletionodoo/addons/base/tests/test_ir_model.py
- odoo/addons/base/views/ir_model_views.xml 1 addition, 0 deletionsodoo/addons/base/views/ir_model_views.xml
Loading
Please register or sign in to comment