From 7e652ab9b5e00507c08763eccc21aedbc61102d1 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 29 Apr 2015 11:32:23 +0700 Subject: [PATCH] order by name --- netforce_clinic/models/report_labor_cost_summary.py | 4 +++- netforce_clinic/models/setting.py | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py index 043dcbe..f51030e 100644 --- a/netforce_clinic/models/report_labor_cost_summary.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -145,6 +145,7 @@ class ReportLaborCostSummary(Model): if not staffs.get(staff.name): staffs[staff.name]={ 'number': staff.number or '', + 'first_name': staff.first_name or "", 'staff_id': staff.id, 'staff_type': staff.type, 'staff_level': level_name, @@ -184,6 +185,7 @@ class ReportLaborCostSummary(Model): for sname in snames: vals=staffs[sname] lvals={ + 'first_name': vals.get("first_name") or "", 'staff_name': sname, 'staff_id': vals.get('staff_id'), 'staff_type': vals.get('staff_type'), @@ -250,7 +252,7 @@ class ReportLaborCostSummary(Model): # run no nlines=[] no=1 - for line in sorted(lines, key=lambda x: x['number']): + for line in sorted(lines, key=lambda x: (x['staff_name'],x['first_name'])): line['no']=no nlines.append(line) no+=1 diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index c2eba2b..f77e690 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -161,8 +161,9 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return - #obj=self.browse(ids)[0] + obj=self.browse(ids)[0] #obj.del_duplicate_staff() + obj.merge_staff() print("Done!") def merge_staff(self,ids,context={}): @@ -171,12 +172,11 @@ class ClinicSetting(Model): print("Only admin!!") return sts={} - print('='*50, 'patients duplicate') db=get_connection() - print('='*50, 'staffs duplicate') for st in get_model("clinic.staff").search_browse([]): name='%s %s'%(st.first_name or '', st.last_name or '') name=name.replace(" ","") + name=''.join([n for n in name if n.isalpha()]) if not sts.get(name): sts[name]=[] sts[name].append({ @@ -226,6 +226,8 @@ class ClinicSetting(Model): res=get_model("clinic.hd.case.staff").search_browse([['staff_id','=',staff_id]]) if len(res)<=0: print('doctor zero delete ', st) + for le in get_model("clinic.labor.cost.entry.line").search_browse([['staff_id','=',staff_id]]): + le.delete() get_model('clinic.staff').delete([staff_id]) else: print('merge doctor... ', st, staff_id, val['date'], val['branch_id'], len(res))