clinic/netforce_clinic/models/hd_case_dialyzer.py

42 lines
2.0 KiB
Python

from netforce.model import Model, fields
class HDCaseDialyzerLine(Model):
_name="clinic.hd.case.dialyzer"
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
hdcase=obj.hd_case_id
res[obj.id]={
'hdcase_date': hdcase.date,
'hdcase_state': hdcase.state,
'nurse_id': hdcase.nurse_id.id,
}
return res
def _get_dlz_state(self,ids,context={}):
res={}
for obj in self.browse(ids):
dlz=obj.dialyzer_id
res[obj.id]=dlz.state
return res
_fields={
"hd_case_id": fields.Many2One("clinic.hd.case","HDCase",on_delete="cascade"),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
"dialyzer_id": fields.Many2One("clinic.dialyzer","Dialyzer",search=True),
"description": fields.Char("Description",search=True),
"use_time":fields.Integer("Use time"),
"max_use_time":fields.Integer("Max use time"),
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
'hdcase_date': fields.Date('Date', function="_get_all",function_multi=True),
"hdcase_state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True,function="_get_all",function_multi=True),
'nurse_id': fields.Many2One('clinic.staff', 'Use by',function="_get_all",function_multi=True),
"state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),("expire","Expire"),('cancelled','Cancelled')],"Status",function="_get_dlz_state"),
}
_order="hd_case_id.date desc"
HDCaseDialyzerLine.register()