Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3293 Widoki

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.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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)
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 19
3894
2
mar 24
1147
1
lip 25
1165
2
mar 25
1426
0
lut 25
1099