diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index b8e643a..d94aeee 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -356,6 +356,12 @@ class Patient(Model): vids=get_model("clinic.visit").search([['patient_id','=',obj.id],['state','in',['draft','pending']]]) for visit in get_model('clinic.visit').browse(vids): visit.write(visit_vals) + if visit_vals.get("doctor_id"): + for hdcase in visit.hd_cases: + for shdcase in hdcase.staffs: + shdcase.write({ + 'staff_id': visit_vals['doctor_id'], + }) for obj in self.browse(ids): if obj.state=='treatment': vals['note']='' diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index f77e690..231451a 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -161,9 +161,23 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return - obj=self.browse(ids)[0] + pts=set() + for vst in get_model("clinic.visit").search_browse([['doctor_id','=',None],['patient_id.dispose','=',False]]): + pt=vst.patient_id + dt=vst.doctor_id + if not dt and pt.doctor_id: + vst.write({ + 'doctor_id': pt.doctor_id.id, + }) + pts.update({pt.name}) + print('-'*50) + for pt in pts: + print(pt) + print('-'*50) + + #obj=self.browse(ids)[0] #obj.del_duplicate_staff() - obj.merge_staff() + #obj.merge_staff() print("Done!") def merge_staff(self,ids,context={}):