diff --git a/netforce_clinic/layouts/clinic_patient_list.xml b/netforce_clinic/layouts/clinic_patient_list.xml index 1fb5a87..1673be0 100644 --- a/netforce_clinic/layouts/clinic_patient_list.xml +++ b/netforce_clinic/layouts/clinic_patient_list.xml @@ -11,7 +11,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_staff_list.xml b/netforce_clinic/layouts/clinic_staff_list.xml index 2b39e67..3287f65 100644 --- a/netforce_clinic/layouts/clinic_staff_list.xml +++ b/netforce_clinic/layouts/clinic_staff_list.xml @@ -10,10 +10,6 @@ - - - - - + diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 73b2518..6e9b61c 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -78,6 +78,12 @@ class Patient(Model): res[obj.id]=','.join([code for code in dpt_codes if code]) return res + def _get_department_names(self,ids,context={}): + res={} + for obj in self.browse(ids): + res[obj.id]=','.join([dpt.name for dpt in obj.departments]) + return res + _fields={ "number": fields.Char("HN Number",required=True,search=True), "trt_no": fields.Char("TRT",search=True), @@ -148,6 +154,7 @@ class Patient(Model): 'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'), 'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walk In"), 'departments': fields.Many2Many("clinic.department","Departments"), + 'department_names': fields.Text("Departments",function="_get_department_names"), 'location': fields.Char("Location",function="_get_location",store=True), #to filter } @@ -210,7 +217,7 @@ class Patient(Model): 'departments': _get_departments, } - _sql_constraints=("clinic_patient_key_uniq","unique(name_check)","name should be unique"), + _sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"), _order="reg_date desc" def check_idcard(self,idcard=''): diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 009ca67..8d5a5dc 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -150,28 +150,15 @@ class ClinicSetting(Model): print("Only admin!!") return # update - for pt in get_model("clinic.patient").search_browse([]): - dpt=pt.department_id - dpt_ids=set() - for cc in pt.cycles: - dp=cc.department_id - vals={} - if not dp: - vals.update({ - 'department_id': dpt.id, - }) - if (dp.day or "").isdigit(): - day=DAYS[int(dp.day)] - vals.update({ - 'day': day, - }) - cc.write(vals) - dp=dp or dpt - dpt_ids.update({dp.id}) - dpt_ids=list(dpt_ids) - pt.write({ - 'departments': [('set',dpt_ids)], - }) + db=get_connection() + res=db.query("select id, day from clinic_patient_cycle") + for r in res: + day=r['day'] or "" + if day.isdigit(): + pc=get_model('clinic.patient.cycle').browse(r['id']) + pc.write({ + 'day': DAYS[int(r['day'])], + }) return ### remove douplicate visit visits={} diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index 5df2668..e371bc5 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -100,6 +100,12 @@ class Staff(Model): res[obj.id]=",".join([d.code for d in obj.departments]) return res + def _get_department_names(self,ids,context={}): + res={} + for obj in self.browse(ids): + res[obj.id]=','.join([dpt.name for dpt in obj.departments]) + return res + _fields={ 'employee_id': fields.Many2One("hr.employee","Employee"), "number": fields.Char("Number",required=True,search=True), @@ -155,6 +161,7 @@ class Staff(Model): 'branch_id': fields.Many2One("clinic.branch","Branch", search=True), "partner_id": fields.Many2One("partner","Contact"), 'departments': fields.Many2Many("clinic.department","Departments"), + 'department_names': fields.Text("Departments",function="_get_department_names"), "location": fields.Char("Location",function="_get_location",store=True), }