clinic/netforce_clinic/models/setting_account_patient.py

25 lines
1.1 KiB
Python

from netforce.model import Model, fields
from netforce.access import get_active_company
class SettingAccountPatient(Model):
_name="clinic.setting.account.patient"
_string="Account Patient"
_fields={
"setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
"patient_id": fields.Many2One("clinic.patient","Patient",domain=[["state","=","admit"]], search=True,required=True),
'partner_id': fields.Many2One("partner","Contact", search=True,required=True),
'type_id': fields.Many2One("clinic.patient.type","Type", search=True,required=True),
'hn': fields.Char("HN", search=True),
'card_no': fields.Char("ID Card",size=13, search=True),
'company_id': fields.Many2One("company","Company"),
}
_defaults={
'setting_id': 1,
"company_id": lambda *a: get_active_company(),
}
_sql_constraints=("clinic_setting_acc_pt_key_uniq","unique(patient_id,partner_id,type_id,hn,card_no)","account patient should be unique"),
_order="type_id,patient_id"
SettingAccountPatient.register()