clinic/netforce_clinic/models/report_staff.py

71 lines
2.4 KiB
Python
Raw Normal View History

2015-02-02 11:12:00 +00:00
from netforce.model import Model, fields, get_model
2015-01-30 11:15:13 +00:00
class ReportStaff(Model):
_name='clinic.report.staff'
_string="Report Staff"
def _get_store(self,ids,context={}):
res={}
for obj in self.browse(ids):
total=len(obj.lines)
res[obj.id]={
'name': total,
}
return res
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
2015-02-02 10:35:47 +00:00
htotal=len(obj.lines)
ptotal=len(obj.patients)
2015-01-30 11:15:13 +00:00
res[obj.id]={
2015-02-02 10:35:47 +00:00
'hdcase_total': htotal,
'patient_total': ptotal,
2015-01-30 11:15:13 +00:00
}
return res
_fields={
2015-02-02 10:35:47 +00:00
'entry_id': fields.Many2One("clinic.labor.cost.entry",'Labor Cost Entry',search=True),
'staff_id': fields.Many2One("clinic.staff",'Staff',search=True),
"staff_type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
2015-01-30 11:15:13 +00:00
'name': fields.Char("Name", function="_get_store",function_multi=True,store=True),
2015-02-02 10:35:47 +00:00
'date_from': fields.Date("From",search=True),
2015-01-30 11:15:13 +00:00
'date_to': fields.Date("To"),
2015-02-02 10:35:47 +00:00
'hdcase_total': fields.Char("HDCase Total", function="_get_all",function_multi=True),
'patient_total': fields.Char("Patient Total", function="_get_all",function_multi=True),
2015-01-30 11:15:13 +00:00
'lines': fields.One2Many("clinic.report.staff.line","report_staff_id","Lines"),
2015-02-02 10:35:47 +00:00
'patients': fields.One2Many("clinic.report.staff.patient","report_staff_id","Patient Lines"),
2015-01-30 11:15:13 +00:00
}
def create(self,vals,**kw):
id=super().create(vals,**kw)
self.function_store([id])
return id
def write(self,ids,vals,**kw):
super().write(ids,vals,**kw)
self.function_store(ids)
2015-02-02 10:35:47 +00:00
def get_data(self,context={}):
2015-02-02 11:12:00 +00:00
refer_id=int(context.get("refer_id","0"))
obj=get_model('clinic.report.staff').browse(refer_id)
lines=[]
count=0
for line in obj.lines:
patient=line.patient_id
hd_case=line.hd_case_id
lines.append({
'no': count,
})
count+=1
data={
'date_from': obj.date_from,
'date_to': obj.date_to,
'staff_name': obj.staff_id.name or '',
'staff_type': obj.staff_type or '',
'lines': lines,
}
2015-02-02 10:35:47 +00:00
return data
2015-01-30 11:15:13 +00:00
ReportStaff.register()