improve report
parent
164e0d378d
commit
b4724e98b8
|
@ -4,5 +4,6 @@
|
|||
<field name="date_to" required="1" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<field name="show_detail"/>
|
||||
<field name="report_type" span="2"/>
|
||||
<field name="show_detail" attrs='{"invisible":[["report_type","!=","detail"]]}'/>
|
||||
</form>
|
||||
|
|
|
@ -15,6 +15,7 @@ class ReportLaborCost(Model):
|
|||
"date_to": fields.Date("To", required=True),
|
||||
"branch_id": fields.Many2One("clinic.branch","Branch"),
|
||||
"department_id": fields.Many2One("clinic.department","Department"),
|
||||
'report_type': fields.Selection([['cross','Cross'],['detail','Detail']],'Type'),
|
||||
'show_detail': fields.Boolean("Show Detail"),
|
||||
}
|
||||
|
||||
|
@ -31,12 +32,14 @@ class ReportLaborCost(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())
|
||||
report_type=defaults.get("report_type","detail")
|
||||
print('defaults ', defaults)
|
||||
res={
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'show_detail': False,
|
||||
'report_type': report_type,
|
||||
}
|
||||
return res
|
||||
|
||||
|
@ -49,6 +52,7 @@ class ReportLaborCost(Model):
|
|||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
show_detail=defaults['show_detail']
|
||||
report_type=defaults['report_type']
|
||||
dom=[]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -57,6 +61,7 @@ class ReportLaborCost(Model):
|
|||
branch_id=obj.branch_id.id
|
||||
department_id=obj.department_id.id
|
||||
show_detail=obj.show_detail
|
||||
report_type=obj.report_type
|
||||
dom.append(['date','>=',date_from])
|
||||
dom.append(['date','<=',date_to])
|
||||
dom.append(['cycle_item_id.state','=', 'validated'])
|
||||
|
@ -129,16 +134,64 @@ class ReportLaborCost(Model):
|
|||
for line in lines:
|
||||
qty=line['qty'] or 0
|
||||
total_hdcase+=qty
|
||||
dlines=[]
|
||||
nlines=[]
|
||||
if report_type=='cross':
|
||||
dom=[
|
||||
['date','>=',date_from],
|
||||
['date','<=',date_to],
|
||||
['labor_cost_id.cycle_item_id.state','=','validated'],
|
||||
]
|
||||
ddata={}
|
||||
ndata={}
|
||||
for line in get_model('clinic.labor.cost.line').search_browse(dom):
|
||||
cost_id=line.labor_cost_id
|
||||
citem=cost_id.cycle_item_id
|
||||
department=citem.department_id
|
||||
dpt_name=department.name or ''
|
||||
qty=line.qty or 0
|
||||
if line.type=='doctor':
|
||||
if dpt_name not in ddata.keys():
|
||||
ddata[dpt_name]=0
|
||||
ddata[dpt_name]+=qty
|
||||
elif line.type=='nurse':
|
||||
if dpt_name not in ndata.keys():
|
||||
ndata[dpt_name]=set()
|
||||
for hdcase in citem.hd_cases:
|
||||
ndata[dpt_name].update({hdcase.id})
|
||||
dlines.append({
|
||||
'name': 'แพทย์',
|
||||
'qty': 'จำนวนครั้ง',
|
||||
})
|
||||
for dt_name,qty in ddata.items():
|
||||
dlines.append({
|
||||
'name': dt_name,
|
||||
'qty': qty,
|
||||
})
|
||||
nlines.append({
|
||||
'name': 'พยาบาล',
|
||||
'qty': 'จำนวนครั้ง',
|
||||
})
|
||||
for dt_name, hdcases in ndata.items():
|
||||
nlines.append({
|
||||
'name': dt_name,
|
||||
'qty': len(hdcases)
|
||||
})
|
||||
data={
|
||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||
'date': date,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'lines': lines,
|
||||
'dlines': dlines,
|
||||
'nlines': nlines,
|
||||
'total_hdcase': total_hdcase,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'show_detail': show_detail,
|
||||
'report_type': report_type,
|
||||
#'ddata': ddata,
|
||||
#'ndata': ndata,
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
From {{date_from}} To {{date_to}}
|
||||
</h4>
|
||||
</center>
|
||||
{{#ifeq report_type "detail"}}
|
||||
<table class="table table-condensed table-striped">
|
||||
<thead>
|
||||
<th>ชั้น</th>
|
||||
|
@ -57,3 +58,34 @@
|
|||
</th>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
{{else}}
|
||||
<table class="table table-bordered">
|
||||
<tbody style="text-align:center">
|
||||
<tr>
|
||||
{{#each dlines }}
|
||||
<th style="text-align:center;width:10%">{{name}}</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
<tr>
|
||||
{{#each dlines }}
|
||||
<td>{{qty}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-bordered">
|
||||
<tbody style="text-align:center">
|
||||
<tr>
|
||||
{{#each nlines }}
|
||||
<th style="text-align:center;width:10%">{{name}}</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
<tr>
|
||||
{{#each nlines }}
|
||||
<td>{{qty}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/ifeq}}
|
||||
|
|
Loading…
Reference in New Issue