44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
from netforce.model import Model, fields
|
||
|
|
||
|
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):
|
||
|
total=len(obj.lines)
|
||
|
res[obj.id]={
|
||
|
'hdcase_total': total,
|
||
|
}
|
||
|
return res
|
||
|
|
||
|
_fields={
|
||
|
'staff_id': fields.Many2One("clinic.staff",'Staff'),
|
||
|
'name': fields.Char("Name", function="_get_store",function_multi=True,store=True),
|
||
|
'date_from': fields.Date("From"),
|
||
|
'date_to': fields.Date("To"),
|
||
|
'hdcase_total': fields.Char("Total", function="_get_all",function_multi=True),
|
||
|
'lines': fields.One2Many("clinic.report.staff.line","report_staff_id","Lines"),
|
||
|
}
|
||
|
|
||
|
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)
|
||
|
|
||
|
ReportStaff.register()
|