From 9b65b7cc3642352996d2efc176ddde727eeacf50 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Sun, 5 Apr 2015 20:45:39 +0700 Subject: [PATCH] report labor cost --- .../layouts/clinic_account_menu.xml | 4 +- netforce_clinic/models/report_labor_cost.py | 42 ++++++++++--------- .../models/report_labor_cost_summary.py | 9 ++-- .../templates/report_labor_cost.hbs | 14 +++++-- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index c3ac482..881f7ed 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -11,8 +11,8 @@
- - + + diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index b1ad915..68241ad 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -56,29 +56,32 @@ class ReportLaborCost(Model): dom.append(['date','>=',date_from]) dom.append(['date','<=',date_to]) if branch_id: - dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id]) + dom.append(['branch_id','=',branch_id]) if department_id: - dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id]) + dom.append(['department_id','=',department_id]) print('dom ', dom) + hdcases={} + for hdcase in get_model("clinic.hd.case").search_browse(dom): + dpt=hdcase.department_id + if dpt.id not in hdcases.keys(): + hdcases[dpt.id]={ + 'name': dpt.name, + 'department_id': dpt.id, + 'branch_id': dpt.branch_id.id, + 'qty':0, + } + hdcases[dpt.id]['qty']+=1 lines=[] - citems={} - for line in get_model("clinic.labor.cost.line").search_browse(dom): - #print('xx') - lcost=line.labor_cost_id - citem=lcost.cycle_item_id - dpt=citem.department_id - qty=line.qty or 0 #XXX - print(citem.id) - import pdb; pdb.set_trace() - if not citem.id not in list(citems.keys()): - print("zzz") - citems[citem.id]=citem - total_hdcase=0 - for citem_id, citem in citems.items(): - for hdcase in citem.hd_cases: - if hdcase.state in ('completed','waitting_payment','paid'): - total_hdcase+=1 + for dpt_id, vals in hdcases.items(): + qty=vals['qty'] or 0 + total_hdcase+=qty + lines.append({ + 'name': vals['name'], + 'branch_id': vals['branch_id'], + 'department_id': vals['department_id'], + 'qty': qty, + }) sub_name='' if department_id: dpt=get_model("clinic.department").browse(department_id) @@ -86,6 +89,7 @@ class ReportLaborCost(Model): elif branch_id: branch=get_model("clinic.branch").browse(branch_id) sub_name="(%s)" % branch.name or "" + data={ 'company_name': '%s %s' % (company.name or "", sub_name), 'date_from': date_from, diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py index 91168c2..24e3ed6 100644 --- a/netforce_clinic/models/report_labor_cost_summary.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -35,15 +35,18 @@ class ReportLaborCostSummary(Model): defaults=context.get("defaults",{}) date_from=defaults.get("date_from", self._get_date_from()) date_to=defaults.get("date_to", self._get_date_to()) + branch_id=int(defaults.get("branch_id","0")) + department_id=int(defaults.get("department_id","0")) staff_type=defaults.get("staff_type","doctor") staff_id=int(defaults.get('staff_id', "0")) - print('defaults ', defaults) res={ 'date': time.strftime("%Y-%m-%d"), 'date_from': date_from, 'date_to': date_to, 'staff_type': staff_type, 'staff_id': staff_id and staff_id or None, + 'department_id': department_id, + 'branch_id': branch_id, 'only_value': True, } return res @@ -55,10 +58,10 @@ class ReportLaborCostSummary(Model): staff_id=defaults['staff_id'] staff_type=defaults['staff_type'] only_value=defaults['only_value'] + department_id=defaults['department_id'] + branch_id=defaults['branch_id'] level_id=None categ_id=None - branch_id=None - department_id=None dom=[] if ids: obj=self.browse(ids)[0] diff --git a/netforce_clinic/templates/report_labor_cost.hbs b/netforce_clinic/templates/report_labor_cost.hbs index aef5dfa..285e4e3 100644 --- a/netforce_clinic/templates/report_labor_cost.hbs +++ b/netforce_clinic/templates/report_labor_cost.hbs @@ -8,17 +8,23 @@ + + {{#each lines }} - + + {{/each}} + +
ชั้นจำนวน HD Case
+ {{name}} + + {{currency qty}} +
Total{{currency total_hdcase}}
-

- {{total_hdcase}} -