clinic/netforce_clinic/models/hd_case_popup_dlz.py

53 lines
1.7 KiB
Python
Raw Normal View History

2015-01-15 05:15:46 +00:00
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"),
2015-01-15 07:37:36 +00:00
'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"),
2015-01-29 14:55:05 +00:00
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
2015-01-15 05:15:46 +00:00
}
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)
2015-02-20 05:16:51 +00:00
2015-01-15 05:15:46 +00:00
_defaults={
'hd_case_id': _get_hd_case_id,
2015-01-15 08:45:11 +00:00
'dialyzer_type': 'low',
'max_use_time': 10,
2015-01-15 05:15:46 +00:00
}
2015-01-15 08:45:11 +00:00
def new_dlz(self,ids,context={}):
obj=self.browse(ids)[0]
hd_case=obj.hd_case_id
2015-03-10 11:45:19 +00:00
res={}
2015-01-15 08:45:11 +00:00
if hd_case:
context['is_wiz']=True
context['pop_id']=obj.id
2015-03-10 11:45:19 +00:00
res=hd_case.new_dialyzer(context=context)
print('res ', res)
return res
2015-01-15 05:15:46 +00:00
def onchange_product(self,context={}):
2015-02-20 05:16:51 +00:00
data=context['data']
product_id=data['product_id']
2015-02-20 10:59:49 +00:00
data['membrane_type']=None
for dlz in get_model("clinic.dialyzer").search_browse([]):
prod=dlz.product_id
if prod.id==product_id:
data['membrane_type']=dlz.membrane_type
break
2015-02-20 05:16:51 +00:00
return data
2015-01-15 05:15:46 +00:00
HDCasePopupDlz.register()