clinic/netforce_clinic/models/cycle_item_line.py

34 lines
1.5 KiB
Python

from netforce.model import Model, fields
from netforce.access import get_active_user, set_active_user
class CycleItemLine(Model):
_name="clinic.cycle.item.line"
_string="Cycle Item Nurse"
def _get_all(self,ids,context={}):
res={}
user_id=get_active_user()
set_active_user(1)
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,
}
set_active_user(user_id)
return res
_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']]),
'department_id': fields.Many2One("clinic.department","Department"),
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
"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),
'categ_id': fields.Many2One("clinic.staff.categ",'Category',domain=[['type','=','nurse']]),
}
CycleItemLine.register()