Hi Everyone!
I need to sort the data by Next Activity Deadline in CRM which is relational field. By default in Odoo, we don't have right to sort any relational field.
Any idea how to do sorting of this relational field?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi Everyone!
I need to sort the data by Next Activity Deadline in CRM which is relational field. By default in Odoo, we don't have right to sort any relational field.
Any idea how to do sorting of this relational field?
Hi. Do you tested storing the field? Odoo needs stored field to do a sort.
I had a similar problem and I solved it by creating a second computed field and use this where required.
Example to get the idea:
@api.multi
def _compute_sorted_related_records(self):
for record in self:
record.sorted_related_records = record.related_records.sorted(
key=lambda r: r.my_sort_field
).ids
sorted_related_records = fields.Many2many(
'related.model',
compute=_compute_sorted_related_records,
)
Ravi Gadhia
I need to sort activity_date_deadline field in CRM which is datetime type field and that field is not stored in database
You can add '_order' comment to sort record while listing out in list view. In that you can assign your field name and sorting method.
Relational field is not working in _order method
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Dec 24
|
59 | ||
|
1
Jun 22
|
3454 | ||
Field __last_update
Solved
|
|
1
Feb 19
|
3718 | |
|
1
Apr 16
|
2776 | ||
|
2
May 15
|
3116 |
specifically which relation field many2one, x2many? field name?