Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
9477 Представления

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

Related Posts Ответы Просмотры Активность
0
февр. 25
1317
0
янв. 25
1138
1
дек. 24
1467
1
июн. 22
5609
1
февр. 19
4983