From 9b82b6f0b2501136bef35bff4054c693cc8bf7e0 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Fri, 27 Feb 2015 14:43:12 +0700 Subject: [PATCH] improve report --- .../layouts/clinic_matching_hdcase.xml | 3 +- .../layouts/clinic_staff_categ_form.xml | 1 + .../layouts/clinic_staff_categ_list.xml | 1 + netforce_clinic/models/matching_hdcase.py | 58 ++++++++++++++----- netforce_clinic/models/setting.py | 21 ++++--- netforce_clinic/models/staff_categ.py | 1 + netforce_clinic/templates/matching_hdcase.hbs | 7 +++ 7 files changed, 70 insertions(+), 22 deletions(-) diff --git a/netforce_clinic/layouts/clinic_matching_hdcase.xml b/netforce_clinic/layouts/clinic_matching_hdcase.xml index 61b69ad..beff827 100644 --- a/netforce_clinic/layouts/clinic_matching_hdcase.xml +++ b/netforce_clinic/layouts/clinic_matching_hdcase.xml @@ -1,5 +1,6 @@
- + + diff --git a/netforce_clinic/layouts/clinic_staff_categ_form.xml b/netforce_clinic/layouts/clinic_staff_categ_form.xml index 2641c7d..c3657ca 100644 --- a/netforce_clinic/layouts/clinic_staff_categ_form.xml +++ b/netforce_clinic/layouts/clinic_staff_categ_form.xml @@ -1,6 +1,7 @@
+ diff --git a/netforce_clinic/layouts/clinic_staff_categ_list.xml b/netforce_clinic/layouts/clinic_staff_categ_list.xml index 6a20945..6e68bc5 100644 --- a/netforce_clinic/layouts/clinic_staff_categ_list.xml +++ b/netforce_clinic/layouts/clinic_staff_categ_list.xml @@ -1,5 +1,6 @@ + diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py index e158068..94770e8 100644 --- a/netforce_clinic/models/matching_hdcase.py +++ b/netforce_clinic/models/matching_hdcase.py @@ -8,17 +8,22 @@ class MatchingHDCase(Model): _transient=True _fields={ - "date": fields.Date("Date", required=True), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), 'file': fields.File("File"), 'state': fields.Selection([["match","Math"],["not_match","Not Match"]],"State"), } - def _get_date(self,context={}): - return time.strftime("%Y-%m-%d") - - _defaults={ - 'date': _get_date, - } + def default_get(self,field_names=None,context={},**kw): + defaults=context.get("defaults",{}) + datenow=time.strftime("%Y-%m-%d") + date_from=defaults.get('date_from',datenow) + date_to=defaults.get('date_to',datenow) + res={ + 'date_from': date_from, + 'date_to': date_to, + } + return res def get_rows(self,fpath=None): if not fpath: @@ -57,13 +62,16 @@ class MatchingHDCase(Model): def get_report_data(self,ids,context={}): hdcases={} - date=time.strftime("%Y-%m-%d") + defaults=self.default_get(context=context) + date_from=defaults.get("date_from") + date_to=defaults.get("date_to") lines=[] state="all" if ids: obj=self.browse(ids)[0] state=obj.state - date=obj.date + date_from=obj.date_from + date_to=obj.date_to if obj.file: fpath=get_file_path(obj.file) rows=self.get_rows(fpath) @@ -105,8 +113,8 @@ class MatchingHDCase(Model): name=name.upper() products[name]=prod['id'] dom=[] - dom.append(['date',">=",obj.date]) - dom.append(['date',"<=",obj.date]) + dom.append(['date',">=",date_from]) + dom.append(['date',"<=",date_to]) dom.append(['state','!=','cancelled']) hdcases={} hdcases2={} @@ -122,14 +130,15 @@ class MatchingHDCase(Model): categ=prod.categ_id if categ and line.reimbursable=='yes': if categ.code=='EPO': - #prod_line.append((prod.name or "").upper()) prod_name=(prod.name or "").split("-") - if len(prod_name) > 1: + if len(prod_name) >= 1: prod_name=prod_name[0] prod_line.append(prod_name) elif categ.code=='FEE': fee_amt=line.amount or 0 - prod_name='-'.join(prod_line) + prod_name='' + if prod_line: + prod_name='-'.join(prod_line) key1='%s-%s-%s-%s'%(date,hn,prod_name,fee_amt) hdcases[key1]={ 'id': hdcase.id, @@ -214,8 +223,16 @@ class MatchingHDCase(Model): lines.append(line_vals) no=1 lines2=[] + total=0 + total_match=0 + total_unmatch=0 for line in sorted(lines,key=lambda x: x['hn']): is_match=line.get('is_match',False) + if is_match: + total_match+=1 + else: + total_unmatch+=1 + total+=1 if state=='not_match' and is_match: continue elif state=='match' and not is_match: @@ -226,10 +243,23 @@ class MatchingHDCase(Model): lines2.append(line) no+=1 lines=lines2 + date='' + if date_from==date_to: + date=date_from data={ 'lines': lines, + 'date_from': date_from, + 'date_to': date_to, 'date': date, + 'total': total, + 'total_match': total_match, + 'total_unmatch': total_unmatch, } return data + def onchange_date(self,context={}): + data=context['data'] + data['date_to']=data['date_from'] + return data + MatchingHDCase.register() diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index bf0c8e8..31d0fbb 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -110,14 +110,21 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return - for citem in get_model("clinic.cycle.item").search_browse([]): - for line in citem.lines: - nurse=line.nurse_id - level=nurse.level_id - if level: - line.write({ - 'level_id': level.id + for st in get_model("clinic.staff").search_browse([]): + level=st.level_id + if level: + if level.name=='TH': + st.write({ + 'categ_id': 3, }) + #for citem in get_model("clinic.cycle.item").search_browse([]): + #for line in citem.lines: + #nurse=line.nurse_id + #level=nurse.level_id + #if level: + #line.write({ + #'level_id': level.id + #}) print("Done!") def update_departments(self,ids,context={}): diff --git a/netforce_clinic/models/staff_categ.py b/netforce_clinic/models/staff_categ.py index 5017b52..1c7438e 100644 --- a/netforce_clinic/models/staff_categ.py +++ b/netforce_clinic/models/staff_categ.py @@ -12,6 +12,7 @@ class StaffCategory(Model): "type": fields.Selection([("doctor","Doctor"),("nurse","Nurse"),('others','Others')],"Type"), 'parent_id': fields.Many2One("clinic.staff.categ","Parent"), 'company_id': fields.Many2One("company","Company"), + 'note': fields.Text("Description"), } _defaults={ diff --git a/netforce_clinic/templates/matching_hdcase.hbs b/netforce_clinic/templates/matching_hdcase.hbs index 5534abe..5a017f4 100644 --- a/netforce_clinic/templates/matching_hdcase.hbs +++ b/netforce_clinic/templates/matching_hdcase.hbs @@ -4,6 +4,13 @@ + + +
+ Total: {{total}} + Match: {{total_match}} + Not Match: {{total_unmatch}} +
Import File Netforce