Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
3296 Visualizações

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.

Avatar
Cancelar
Autor Melhor resposta

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)
Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
ago. 19
3895
2
mar. 24
1148
1
jul. 25
1170
2
mar. 25
1440
0
fev. 25
1102