콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
9594 화면

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
1472
0
1월 25
1232
1
12월 24
1623
1
6월 22
5826
Field __last_update 해결 완료
1
2월 19
5117