clinic/netforce_clinic/models/staff_level.py

44 lines
1.3 KiB
Python
Raw Permalink Normal View History

2014-11-21 02:39:26 +00:00
from netforce.model import Model, fields, get_model
2014-11-02 01:26:42 +00:00
from netforce.access import get_active_company
class StaffLevel(Model):
_name="clinic.staff.level"
_string="Staff Level"
2014-11-26 11:35:44 +00:00
_key=["name"]
2015-01-09 05:19:52 +00:00
_multi_company=True
2014-11-02 01:26:42 +00:00
_fields={
"name": fields.Char("Name",required=True,search=True),
2014-11-21 02:39:26 +00:00
'description': fields.Text("Description", search=True),
2014-11-02 01:26:42 +00:00
'sequence': fields.Integer("Sequence"),
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),("nurse","Nurse")],"Staff Type",required=True, search=True),
2015-01-09 05:19:52 +00:00
'company_id': fields.Many2One("company","Company"),
2014-11-02 01:26:42 +00:00
}
_defaults={
"company_id": lambda *a: get_active_company(),
'sequence': 0,
2014-11-25 14:20:30 +00:00
'type': 'nurse',
2014-11-02 01:26:42 +00:00
}
_order="sequence"
2014-11-21 02:39:26 +00:00
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)
2014-11-21 02:39:26 +00:00
return {
'next': {
'name': 'clinic_staff_level',
2014-11-21 02:39:26 +00:00
'mode': 'form',
'active_id': new_id,
},
'flash': 'Copy has been succcesfully',
}
StaffLevel.register()