clinic/netforce_clinic/models/department.py

35 lines
1.1 KiB
Python

from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class Department(Model):
_name="clinic.department"
_string="Department"
_key=['code']
_fields={
"name": fields.Char("Name",required=True,search=True),
"code": fields.Char("Code",search=True),
"parent_id": fields.Many2One("clinic.department", "Parent"),
'company_id': fields.Many2One("company","Company"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
"pick_out_journal_id": fields.Many2One("stock.journal","Stock Journal",required=True),
'patients': fields.One2Many("clinic.patient","department_id","Patients"),
'staffs': fields.One2Many("clinic.staff","department_id","Staffs"),
'active': fields.Boolean("Active"),
}
def _get_branch(self,context={}):
b_ids=get_model('clinic.branch').search([])
if b_ids:
return b_ids[0]
_defaults={
'company_id': lambda *a: get_active_company(),
'branch_id': _get_branch,
'active': True,
}
_order="code"
Department.register()