clinic/netforce_clinic/models/schedule.py

30 lines
939 B
Python

from netforce.model import Model, fields
from netforce.access import get_active_company
class Schedule(Model):
_name="clinic.schedule"
_string="Schedule"
#_field_name="cycle_id"
def _get_name(self,ids,context={}):
res={}
for obj in self.browse(ids):
total_nurse=len(obj.nurses)
res[obj.id]='Cycle: %s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
return res
_fields={
"name": fields.Char("Name",function="_get_name"),
'cycle_id': fields.Many2One("clinic.cycle","Cycle",required=True),
"time_start": fields.DateTime("Time Start",required=True),
"time_stop": fields.DateTime("Time Stop",required=True),
'company_id': fields.Many2One("company","Company"),
'nurses': fields.Many2Many('clinic.nurse','Nurses'),
}
_defaults={
"company_id": lambda *a: get_active_company(),
}
Schedule.register()