report labor cost summary

conv_bal
watcha.h 2015-02-17 16:57:34 +07:00
parent 3874920314
commit 85712d9e25
3 changed files with 23 additions and 17 deletions

View File

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

View File

@ -17,6 +17,7 @@ class ReportLaborCostSummary(Model):
"type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
'department_id': fields.Many2One("clinic.department","Department"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'only_value': fields.Boolean("Only Value Exist"),
}
def _get_date_from(self,context={}):
@ -32,6 +33,7 @@ class ReportLaborCostSummary(Model):
'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': _get_date_from,
'date_to': _get_date_to,
'only_value': True,
}
def get_report_data(self,ids,context={}):
@ -40,19 +42,27 @@ class ReportLaborCostSummary(Model):
date_to=time.strftime(fmt)
company_id=get_active_company()
comp=get_model("company").browse(company_id)
_type=None
staff_type=None
staff_id=None
only_value=False
dom=[]
if ids:
obj=self.browse(ids)[0]
date_from=obj.date_from
date_to=obj.date_to
_type=obj.type
staff_id=obj.staff_id.id
staff_type=obj.type
only_value=obj.only_value
dom.append(['date','>=',date_from])
dom.append(['date','<=',date_to])
if _type:
dom.append(['type','=',_type])
if staff_id:
dom.append(['staff_id','=',staff_id])
if staff_type:
dom.append(['type','=',staff_type])
if only_value:
dom.append(['amount','!=',0])
staffs={}
print('dom ', dom)
for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
@ -68,24 +78,20 @@ class ReportLaborCostSummary(Model):
},
}
if not staffs[staff.name].get(dpt.name):
staffs[staff.name]={
'staff_id': staff.id,
staffs[staff.name].update({
dpt.name: {
'amt':amt,
}
}
staffs[staff.name][dpt.name]['amt']+=amt
'amt': 0,
}})
staffs[staff.name][dpt.name]['amt']+=amt
lines=[]
dpts=get_model("clinic.department").search_read([],['name'])
dpts=sorted(dpts, key=lambda b: b['name'])
no=1
staff_types=set()
snames=sorted(staffs.keys()) #sort by staff name
for sname in snames:
vals=staffs[sname]
print(">> ", vals.get('staff_name'), ' ', sname)
lvals={
'no': no,
'staff_name': sname,
@ -94,6 +100,7 @@ class ReportLaborCostSummary(Model):
total=0
lvals['sub_lines']=[]
for dpt in dpts:
amt=0 #solve bug
dname=dpt['name'] or ''
vals2=vals.get(dname)
if vals2:

View File

@ -92,9 +92,6 @@
<div>
<a href="#name=clinic_hd_case">{{t "HD Cases"}}</a>
</div>
<div>
<a href="#name=clinic_matching_hdcase">{{t "HD Cases Matching"}}</a>
</div>
<div>
<a href="#name=clinic_shop">{{t "RD Shop"}}</a>
</div>