clinic/netforce_clinic/models/hd_case_popup_dlz.py

38 lines
1.2 KiB
Python

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"),
'product_id': fields.Many2One("product", "Product",required=True),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
"max_use_time": fields.Integer("Max Use Time"),
"exp_date": fields.Date("Expiry Date"),
"note": fields.Text("Note"),
}
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,
'dialyzer_type': 'low',
'max_use_time': 10,
}
def new_dlz(self,ids,context={}):
obj=self.browse(ids)[0]
hd_case=obj.hd_case_id
if hd_case:
context['is_wiz']=True
context['pop_id']=obj.id
return hd_case.new_dialyzer(context=context)
HDCasePopupDlz.register()