Here is my prefer way to force myself to deal with 'self' as a recordset to avoid singleton error when dealing with it. (on a different note, I have used account_count in _order before and it has store=True and the error is not getting triggered. Only when I remove store=True, the 0 appointment error is triggered but now I lost the _order with the appointment_count) @api.depends('appointment_ids') def _compute_appointment_count(self): recordsets = self appointment_group = self.env['hospital.appointment'].read_group( domain=[('state', '=', 'done')], fields=['patient_id'], groupby=['patient_id']) for appointment in appointment_group: print('HospitalPatient _compute_appointment_count : ', appointment) patient_id = appointment.get('patient_id')[0] patient_rec = recordsets.browse(patient_id) patient_rec.appointment_count = appointment['patient_id_count'] recordsets -= patient_rec for rec in recordsets: print('HospitalPatient _compute_appointment_count : ', rec.name) rec.appointment_count = 0
Excelente explicacion ... Cada vez que veo tus videos aprendo algo nuevo. Gracias por compartir
nice video, it was a complicated topic you explain very well
Glad it was helpful!
Clear explanation. Thank you
thanks dear
thank you so much for this video brother .. it helps a lot to me ........
You are most welcome
Fantastic explanation -- thank you!
Glad it was helpful!
Here is my prefer way to force myself to deal with 'self' as a recordset to avoid singleton error when dealing with it. (on a different note, I have used account_count in _order before and it has store=True and the error is not getting triggered. Only when I remove store=True, the 0 appointment error is triggered but now I lost the _order with the appointment_count)
@api.depends('appointment_ids')
def _compute_appointment_count(self):
recordsets = self
appointment_group = self.env['hospital.appointment'].read_group(
domain=[('state', '=', 'done')], fields=['patient_id'], groupby=['patient_id'])
for appointment in appointment_group:
print('HospitalPatient _compute_appointment_count : ', appointment)
patient_id = appointment.get('patient_id')[0]
patient_rec = recordsets.browse(patient_id)
patient_rec.appointment_count = appointment['patient_id_count']
recordsets -= patient_rec
for rec in recordsets:
print('HospitalPatient _compute_appointment_count : ', rec.name)
rec.appointment_count = 0