improve report

conv_bal
watcha.h@almacom.co.th 2015-04-08 16:24:30 +07:00
parent f8521a2e16
commit 164e0d378d
10 changed files with 63 additions and 24 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="department_id" span="2"/>
<field name="branch_id" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
</form>

View File

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

View File

@ -2,10 +2,10 @@
<field name="date" mode="month" onchange="onchange_date" span="2"/>
<field name="date_from" required="1" span="2"/>
<field name="date_to" required="1" span="2"/>
<field name="staff_type" onchange="onchange_type" span="2"/>
<field name="staff_id" domain='[["type","=",staff_type]]' span="2"/>
<field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<field name="staff_type" onchange="onchange_type" span="2"/>
<field name="staff_id" domain='[["type","=",staff_type]]' span="2"/>
<field name="categ_id" domain='[["type","=","nurse"]]' span="2"/>
<field name="level_id" span="2"/>
<field name="only_value" span="2"/>

View File

@ -157,7 +157,6 @@ class HDCase(Model):
'dlz_use': dlz_use,
'dlz_max': dlz_max,
}
print('no ', no)
set_active_user(user_id)
return res

View File

@ -39,7 +39,16 @@ class ReportLaborCostDetail(Model):
date_to=self._get_date_to()
staff_type=defaults.get("staff_type","doctor")
staff_id=int(defaults.get('staff_id', "0"))
department_id=int(defaults.get('department_id', "0"))
print('defaults ', defaults)
department_id=defaults.get('department_id')
if department_id:
department_id=int(department_id)
branch_id=defaults.get('branch_id')
if branch_id:
branch_id=int(branch_id)
if not branch_id and department_id:
dpt=get_model('clinic.department').browse(department_id)
branch_id=dpt.branch_id.id
res={
'date': time.strftime("%Y-%m-%d"),
'date_from': date_from,
@ -47,6 +56,7 @@ class ReportLaborCostDetail(Model):
'type': staff_type,
'staff_id': staff_id and staff_id or None,
'department_id': department_id and department_id or None,
'branch_id': branch_id,
}
return res
@ -59,6 +69,7 @@ class ReportLaborCostDetail(Model):
staff_type=defaults.get("type")
staff_id=defaults.get("staff_id")
department_id=defaults.get("department_id")
branch_id=defaults.get("branch_id")
dom=[]
if ids:
obj=self.browse(ids)[0]
@ -67,6 +78,7 @@ class ReportLaborCostDetail(Model):
staff_id=obj.staff_id.id
staff_type=obj.type
department_id=obj.department_id.id
branch_id=obj.branch_id.id
dom.append(['date','>=',date_from])
dom.append(['date','<=',date_to])
if staff_id:
@ -75,6 +87,8 @@ class ReportLaborCostDetail(Model):
dom.append(['type','=',staff_type])
if department_id:
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
if branch_id:
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
def replace_quote(dom=""):
return dom.replace("'","\"")
@ -131,9 +145,18 @@ class ReportLaborCostDetail(Model):
department_name=get_model("clinic.department").browse(department_id).name or ""
# link to sub detail
show_count=0
show_dpt=[]
if department_name:
show_dpt.append(department_name)
if branch_id:
for dpt in get_model("clinic.department").search_read([['branch_id','=',branch_id]],['name']):
show_dpt.append(dpt['name'])
show_all=False
if not department_id and not branch_id:
show_all=True
for dpt in dpts:
show_link=True
if dpt['name']!=department_name and department_name!='':
if dpt['name'] not in show_dpt and not show_all:
show_link=False
show_count+=1
dpt.update({
@ -210,7 +233,8 @@ class ReportLaborCostDetail(Model):
'staff_name': staff_name,
'staff_id': staff_id,
'staff_type': staff_type,
'department_id': "0", #XXX
'department_id': department_id,
'branch_id': branch_id,
'date_from': date_from,
'date_to': date_to,
'dpts': dpts,

View File

@ -13,9 +13,9 @@ class ReportLaborCostSubDetail(Model):
"date": fields.Date("Month"),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
'department_id': fields.Many2One("clinic.department","Department"),
'staff_id': fields.Many2One("clinic.staff","Staff"),
"staff_type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'department_id': fields.Many2One("clinic.department","Department"),
}
@ -38,16 +38,24 @@ class ReportLaborCostSubDetail(Model):
date_to=self._get_date_to()
staff_type=defaults.get("staff_type","doctor")
staff_id=int(defaults.get('staff_id', "0"))
department_id=int(defaults.get('department_id', "0"))
department_id=defaults.get('department_id')
if department_id:
department_id=int(department_id)
branch_id=defaults.get('branch_id')
if branch_id:
branch_id=int(branch_id)
if not branch_id and department_id:
dpt=get_model("clinic.department").browse(department_id)
branch_id=dpt.branch_id.id
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 and department_id or None,
'department_id': department_id,
'branch_id': branch_id,
}
print('res ', res)
return res
def get_report_data(self,ids,context={}):
@ -58,6 +66,7 @@ class ReportLaborCostSubDetail(Model):
date_to=defaults.get("date_to")
staff_type=defaults.get("staff_type")
staff_id=defaults.get("staff_id")
branch_id=defaults.get("branch_id")
department_id=defaults.get("department_id")
staff_name=''
dom=[]
@ -69,6 +78,7 @@ class ReportLaborCostSubDetail(Model):
staff_name=obj.staff_id.name or ""
staff_type=obj.staff_type
department_id=obj.department_id.id
branch_id=obj.branch_id.id
dom.append(['date','>=',date_from])
dom.append(['date','<=',date_to])
if staff_id and staff_type=='doctor':
@ -79,6 +89,8 @@ class ReportLaborCostSubDetail(Model):
dom.append(['type','=',staff_type])
if department_id:
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
if branch_id:
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
if not staff_id:
return {}
def replace_quote(dom=""):

View File

@ -245,6 +245,8 @@ class ReportLaborCostSummary(Model):
'total_hdcase': total_hdcase or 0,
'total_cost': round(total_cost,0) or 0,
'staff_type': staff_type,
'branch_id': branch_id,
'department_id': department_id,
}
return data

View File

@ -25,8 +25,8 @@ class ReportShop(Model):
weekday, total_day=monthrange(int(year), int(month))
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
date_from=defaults.get('date',date)
date_to=defaults.get('date',date)
#date_from=defaults.get('date',date)
#date_to=defaults.get('date',date)
product_id=defaults.get('product_id')
branch_id=defaults.get('branch_id',None)

View File

@ -9,7 +9,7 @@
<table class="table table-condensed table-striped">
<thead>
<th>ชั้น</th>
<th style="text-align:right">รวม</th>
<th style="text-align:right">รวมจำนวนครั้ง</th>
</thead>
<tbody>
{{#each lines }}

View File

@ -18,20 +18,20 @@
<th></th>
</tr>
<tr>
<th rowspan="2">#</th>
<th rowspan="2">รหัส</th>
<th rowspan="3">#</th>
<th rowspan="3">รหัส</th>
{{#ifeq staff_type "nurse"}}
<th rowspan="2">ชื่อ-สกุล</th>
<th rowspan="2">ตำแหน่ง</th>
<th rowspan="2">หมวดหมู่</th>
<th rowspan="3">ชื่อ-สกุล</th>
<th rowspan="3">ตำแหน่ง</th>
<th rowspan="3">หมวดหมู่</th>
{{else}}
<th rowspan="2" colspan="3">ชื่อ-สกุล</th>
<th rowspan="3" colspan="3">ชื่อ-สกุล</th>
{{/ifeq}}
{{#each dpts}}
<th style="text-align:right">{{name}}</th>
{{/each}}
</th>
<th rowspan="2" style="text-align:right;">รวม</th>
<th rowspan="3" style="text-align:right;">รวม</th>
</tr>
</thead>
<tbody>
@ -52,11 +52,11 @@
{{/ifeq}}
{{#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>
<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}}&defaults.branch_id={{../branch_id}}">{{currency amt zero=""}}</a>
</td>
{{/each}}
<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}}">{{currency total zero=""}}</a>
<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.branch_id={{../branch_id}}">{{currency total zero=""}}</a>
</td>
</tr>
{{/each}}