clinic/netforce_clinic/models/staff_rotation.py

65 lines
2.1 KiB
Python
Raw Normal View History

2015-02-27 16:10:50 +00:00
import time
2014-11-05 05:06:43 +00:00
from netforce.model import Model, fields
2014-11-12 11:13:23 +00:00
from netforce.access import get_active_company
2014-11-05 05:06:43 +00:00
2014-11-25 15:22:50 +00:00
class StaffRotation(Model):
_name="clinic.staff.rotation"
_string="Staff Rotation"
2015-01-09 05:19:52 +00:00
_multi_company=True
2014-11-05 05:06:43 +00:00
2015-03-03 02:32:45 +00:00
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
staff=obj.staff_id
res[obj.id]={
'staff_name': staff.name or "",
}
return res
2014-11-05 05:06:43 +00:00
_fields={
2015-02-27 16:10:50 +00:00
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
"staff_id": fields.Many2One("clinic.staff","Staff", search=True),
2015-02-27 16:10:50 +00:00
'categ_id': fields.Many2One("clinic.staff.categ","Category",search=True),
"level_id": fields.Many2One("clinic.staff.level","Level", search=True),
2014-11-12 11:13:23 +00:00
"hire_date": fields.Date("Hire Date", search=True),
"resign_date": fields.Date("Resign Date", search=True),
2014-11-05 05:06:43 +00:00
"wage": fields.Float("Wage"),
2014-11-23 13:44:25 +00:00
"max_cycle": fields.Integer("Max Cycle"),
2015-02-27 16:10:50 +00:00
"ot_per_cycle": fields.Float("OT/Cycle"),
2014-11-05 05:06:43 +00:00
"note": fields.Text("Note"),
2014-11-12 11:13:23 +00:00
'company_id': fields.Many2One("company","Company"),
2015-02-27 16:10:50 +00:00
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
2015-03-03 02:32:45 +00:00
'staff_name': fields.Char("Staff Name", function="_get_all",function_multi=True,store=True), #XXX
2014-11-12 11:13:23 +00:00
}
2015-02-27 16:10:50 +00:00
2014-11-12 11:13:23 +00:00
_defaults={
"company_id": lambda *a: get_active_company(),
2015-02-27 16:10:50 +00:00
'hire_date': time.strftime("%Y-%m-%d"),
'state': 'draft',
'type': 'nurse',
2014-11-05 05:06:43 +00:00
}
2015-02-27 16:10:50 +00:00
def to_draft(self,ids,context={}):
for obj in self.browse(ids):
obj.write({
'state': 'draft',
})
def approve(self,ids,context={}):
for obj in self.browse(ids):
obj.write({
'state': 'approved',
})
2015-03-03 02:32:45 +00:00
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)
2015-02-27 16:10:50 +00:00
2014-11-25 15:22:50 +00:00
StaffRotation.register()