Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3294 Vistas

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
Descartar
Autor Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
ago 19
3895
2
mar 24
1148
1
jul 25
1167
2
mar 25
1429
0
feb 25
1100