from netforce.model import Model, fields, get_model class HDCasePopupDlz(Model): _name="clinic.hd.case.popup.dlz" _transient=True _fields={ "hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"), "note": fields.Text("Description"), } def _get_hd_case_id(self,context={}): hd_case_id=context.get("refer_id") print("hd case deault") if not hd_case_id: return None return int(hd_case_id) _defaults={ 'hd_case_id': _get_hd_case_id, } HDCasePopupDlz.register()