clinic/netforce_clinic/models/cycle_item_line.py

34 lines
1.5 KiB
Python
Raw Permalink Normal View History

from netforce.model import Model, fields
2015-06-03 04:39:08 +00:00
from netforce.access import get_active_user, set_active_user
2014-10-26 08:48:51 +00:00
class CycleItemLine(Model):
_name="clinic.cycle.item.line"
_string="Cycle Item Nurse"
2014-10-26 08:48:51 +00:00
2015-04-27 10:53:47 +00:00
def _get_all(self,ids,context={}):
res={}
2015-06-03 04:39:08 +00:00
user_id=get_active_user()
set_active_user(1)
2015-04-27 10:53:47 +00:00
for obj in self.browse(ids):
citem=obj.cycle_item_id
pt_total=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment','paid')])
res[obj.id]={
'cstate': citem.state,
'pt_total': pt_total,
}
2015-06-03 04:39:08 +00:00
set_active_user(user_id)
2015-04-27 10:53:47 +00:00
return res
2014-10-26 08:48:51 +00:00
_fields={
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
'level_id': fields.Many2One("clinic.staff.level", "Level",),
'nurse_id': fields.Many2One("clinic.staff",'Nurse',domain=[['type','=','nurse']]),
2015-01-18 10:31:54 +00:00
'department_id': fields.Many2One("clinic.department","Department"),
2015-01-22 07:20:04 +00:00
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
2015-04-27 10:53:47 +00:00
"cstate": fields.Selection([("draft","Draft"),('pending','Pending'),("validated","Validated")],"Status",function="_get_all",function_multi=True),
"pt_total": fields.Integer("Patients",function="_get_all",function_multi=True),
2015-02-08 08:48:08 +00:00
'categ_id': fields.Many2One("clinic.staff.categ",'Category',domain=[['type','=','nurse']]),
2014-10-26 08:48:51 +00:00
}
CycleItemLine.register()