跳至内容
菜单
此问题已终结
4 回复
9530 查看

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?

形象
丢弃

specifically which relation field many2one, x2many? field name?

最佳答案

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

相关帖文 回复 查看 活动
0
2月 25
1388
0
1月 25
1170
1
12月 24
1536
1
6月 22
5681
1
2月 19
5027