clinic/netforce_clinic/models/schedule.py

44 lines
1.3 KiB
Python
Raw Normal View History

2014-10-28 15:16:16 +00:00
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)
2014-11-01 17:30:48 +00:00
res[obj.id]='%s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
2014-10-28 15:16:16 +00:00
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"),
2014-11-01 06:04:30 +00:00
'nurses': fields.Many2Many('clinic.personal','Nurses'), # XXX domain
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State'),
2014-10-28 15:16:16 +00:00
}
_defaults={
"company_id": lambda *a: get_active_company(),
}
2014-11-01 17:30:48 +00:00
2014-11-01 06:04:30 +00:00
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'confirmed',
})
def to_draft(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'draft',
})
2014-10-28 15:16:16 +00:00
Schedule.register()