clinic/netforce_clinic/models/staff_level.py

44 lines
1.3 KiB
Python

from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class StaffLevel(Model):
_name="clinic.staff.level"
_string="Staff Level"
_key=["name"]
_multi_company=True
_fields={
"name": fields.Char("Name",required=True,search=True),
'description': fields.Text("Description", search=True),
'sequence': fields.Integer("Sequence"),
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),("nurse","Nurse")],"Staff Type",required=True, search=True),
'company_id': fields.Many2One("company","Company"),
}
_defaults={
"company_id": lambda *a: get_active_company(),
'sequence': 0,
'type': 'nurse',
}
_order="sequence"
def copy(self,ids,context={}):
obj=self.browse(ids)[0]
vals={
'name': '%s (copy)'%obj.name,
'description': obj.description,
'type': obj.type,
}
new_id=get_model("clinic.staff.level").create(vals)
return {
'next': {
'name': 'clinic_staff_level',
'mode': 'form',
'active_id': new_id,
},
'flash': 'Copy has been succcesfully',
}
StaffLevel.register()