update doctor after change from patient profile

conv_bal
watcha.h@almacom.co.th 2015-04-29 16:00:24 +07:00
parent f54963aa4c
commit da37172298
2 changed files with 22 additions and 2 deletions

View File

@ -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']=''

View File

@ -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={}):