Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
13482 Lượt xem

I want to change the timesheet grid so the lines are sorted in alphabetical order according to the project name.

I already tried to order the records by adding this :

_order = 'project_id asc'

But it gives a weird sorting where the lines which have a timesheet on monday are sorted correctly, and THEN the lines which have a timesheet on tuesday BUT NOT ON MONDAY are sorted correctly, and then the lines which have a timesheet on wednesday BUT NOT ON MONDAY OR TUESDAY, etc.

I would like to get a global sort of all the lines, without being dependent of the timesheet entries.


Edit : Here's a picture of what kind of sorting I get : https://ibb.co/JFzCRTZ

(Project names are confidential, but each "group of lines" you can identify on the picture is ordered in alphabetical order)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Try this

1. add a related field on timesheet entries model 

project_name = fields.Char(string="Project Name", related="project_id.name",store=True)

2. add this after _inherit descriptor

_order = "project_name asc"


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 6 22
1265
1
thg 5 22
3394
0
thg 11 17
6350
1
thg 11 23
5233
0
thg 5 23
1878