From da3717229874c80be879df4a9d5d8668c19c6ba5 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 29 Apr 2015 16:00:24 +0700 Subject: [PATCH] update doctor after change from patient profile --- netforce_clinic/models/patient.py | 6 ++++++ netforce_clinic/models/setting.py | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) 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={}):