filter by category

conv_bal
watcha.h 2015-02-18 09:07:07 +07:00
parent 018f9a1f95
commit 6e8d3806f0
3 changed files with 35 additions and 0 deletions

View File

@ -4,5 +4,6 @@
<field name="date_to" required="1" span="2"/>
<field name="type" onchange="onchange_type" span="2"/>
<field name="staff_id" domain='[["type","=",type]]' span="2"/>
<field name="categ_id" span="2"/>
<field name="only_value" span="2"/>
</form>

View File

@ -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']=[]

View File

@ -2,6 +2,9 @@
<table class="table table-condensed table-striped">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th style="text-align:center" colspan="{{comp_span}}">{{comp_name}}</th>
@ -9,7 +12,10 @@
</tr>
<tr>
<th rowspan="2">#</th>
<th rowspan="2">Number</th>
<th rowspan="2">Name</th>
<th rowspan="2">Level</th>
<th rowspan="2">Category</th>
{{#each dpts}}
<th style="text-align:right">{{name}}</th>
{{/each}}
@ -21,9 +27,12 @@
{{#each lines }}
<tr>
<td>{{no}}</th>
<td>{{number}}</th>
<td>
{{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
</td>
<td>{{staff_level}}</th>
<td>{{categ_name}}</th>
{{#each sub_lines}}
<td style="text-align:right;">
<a href="#name=clinic_report_labor_cost_detail&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.staff_type={{../staff_type}}&defaults.staff_id={{../staff_id}}&defaults.department_id={{dpt_id}}">{{currency amt zero=""}}</a>
@ -36,6 +45,9 @@
{{/each}}
</tbody>
<tfoot>
<th></th>
<th></th>
<th></th>
<th>รวม</th>
<th style="text-align:right"></th>
{{#each total_lines}}