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

Hello, 


With Odoo Studio I added a smart button where it counts the number of times the record appears with the calendar.

Odoo Studio automatically does this:


results = self.env['calendar.event'].read_group([('x_studio_physician', 'in', self.ids)], 'x_studio_physician', 'x_studio_physician')dic = {}for x in results: dic[x['x_studio_physician'][0]] = x['x_studio_physician_count']for record in self: record['x_x_studio_physician__calendar_event_count'] = dic.get(record.id, 0)


I add a pipeline status bar to calendar so I would like to count only one specific state or to count all that are different from a specific one.



Thanks in advance for your help.

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

If for someone the answer that I got reading in books is useful, here it goes:

The first part of read_group is the domain, so you just need to include the additional conditions you wanted.

results = self.env ['calendar.event']. read_group (['&',('x_studio_physician', 'in', self.ids),('x_studio_status','=','specific status')], 'x_studio_physician', 'x_studio_physician') dic = {} for x in results: dic [ x ['x_studio_physician'] [0]] = x ['x_studio_physician_count'] for record in self: record ['x_x_studio_physician__calendar_event_count'] = dic.get (record.id, 0)
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 19
3899
2
thg 3 24
1157
1
thg 7 25
1184
2
thg 3 25
1467
0
thg 2 25
1112