From 6e8d3806f0cf9b081393e09e88412d1a900cce2f Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Wed, 18 Feb 2015 09:07:07 +0700 Subject: [PATCH] filter by category --- .../clinic_report_labor_cost_summary.xml | 1 + .../models/report_labor_cost_summary.py | 22 +++++++++++++++++++ .../templates/report_labor_cost_summary.hbs | 12 ++++++++++ 3 files changed, 35 insertions(+) diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml index 63843f5..c6227b7 100644 --- a/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml +++ b/netforce_clinic/layouts/clinic_report_labor_cost_summary.xml @@ -4,5 +4,6 @@ + diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py index f3c8ded..8d01395 100644 --- a/netforce_clinic/models/report_labor_cost_summary.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -16,6 +16,8 @@ class ReportLaborCostSummary(Model): 'staff_id': fields.Many2One("clinic.staff","Staff"), "type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"), 'department_id': fields.Many2One("clinic.department","Department"), + 'level_id': fields.Many2One("clinic.staff.level","Level"), + 'categ_id': fields.Many2One("clinic.staff.categ","Category"), 'branch_id': fields.Many2One("clinic.branch","Branch"), 'only_value': fields.Boolean("Only Amount"), } @@ -44,6 +46,8 @@ class ReportLaborCostSummary(Model): staff_id=None staff_type=res['type'] only_value=res['only_value'] + level_id=None + categ_id=None dom=[] if ids: obj=self.browse(ids)[0] @@ -51,6 +55,8 @@ class ReportLaborCostSummary(Model): date_to=obj.date_to staff_id=obj.staff_id.id staff_type=obj.type + level_id=obj.level_id.id + categ_id=obj.categ_id.id only_value=obj.only_value dom.append(['date','>=',date_from]) dom.append(['date','<=',date_to]) @@ -60,6 +66,8 @@ class ReportLaborCostSummary(Model): dom.append(['type','=',staff_type]) if only_value: dom.append(['amount','!=',0]) + if categ_id: + dom.append(['staff_id.categ_id','=',categ_id]) staffs={} for line in get_model("clinic.labor.cost.line").search_browse(dom): lcost=line.labor_cost_id @@ -67,10 +75,20 @@ class ReportLaborCostSummary(Model): dpt=citem.department_id amt=line.amount or 0 staff=line.staff_id + categ_name='' + categ_id=None + categ=staff.categ_id + if categ: + categ_id=categ.id + categ_name=categ.name or "" if not staffs.get(staff.name): staffs[staff.name]={ + 'number': staff.number or '', 'staff_id': staff.id, 'staff_type': staff.type, + 'staff_level': staff.level_id.name, + 'categ_name': categ_name, + 'categ_id': categ_id, dpt.name: { 'amt': 0, }, @@ -94,6 +112,10 @@ class ReportLaborCostSummary(Model): 'staff_name': sname, 'staff_id': vals.get('staff_id'), 'staff_type': vals.get('staff_type'), + 'staff_level': vals.get('staff_level'), + 'categ_name': vals.get('categ_name'), + 'categ_id': vals.get('categ_id'), + 'number': vals.get("number"), } total=0 lvals['sub_lines']=[] diff --git a/netforce_clinic/templates/report_labor_cost_summary.hbs b/netforce_clinic/templates/report_labor_cost_summary.hbs index ef2c8ae..dd18f17 100644 --- a/netforce_clinic/templates/report_labor_cost_summary.hbs +++ b/netforce_clinic/templates/report_labor_cost_summary.hbs @@ -2,6 +2,9 @@ + + + @@ -9,7 +12,10 @@ + + + {{#each dpts}} {{/each}} @@ -21,9 +27,12 @@ {{#each lines }} + + + + {{#each total_lines}}
{{comp_name}}
#Number NameLevelCategory{{name}}
{{no}} + {{number}} {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}} {{staff_level}} + {{categ_name}} {{#each sub_lines}} {{currency amt zero=""}} @@ -36,6 +45,9 @@ {{/each}}
รวม