new & drop dlz on hd case option

production
watcha.h 2015-11-05 11:36:02 +07:00
parent 1a408090c3
commit d8fcfdb126
5 changed files with 26 additions and 0 deletions

View File

@ -6,6 +6,7 @@
<field name="membrane_type" required="1" span="6"/>
<field name="exp_date" span="6"/>
<field name="note" span="6"/>
<field name="drop_old" span="6"/>
<foot>
<button string="Validate" type="success" method="new_dlz"/>
</foot>

View File

@ -56,6 +56,7 @@
<field name="use_time"/>
<field name="max_use_time"/>
<field name="description"/>
<field name="state"/>
</list>
</field>
<field name="note"/>

View File

@ -1305,7 +1305,20 @@ class HDCase(Model):
}
def new_dialyzer(self,ids,context={}):
'''
drop old one and create new dlz
'''
obj=self.browse(ids)[0]
if context.get('drop_old'):
for dlz_line in obj.dialyzers:
dlz=dlz_line.dialyzer_id
dlz_line.write({
'use_time': dlz.use_time,
})
dlz.write({
'state': 'drop',
})
is_wiz=context.get("is_wiz")
dlz_vals={}
if is_wiz:

View File

@ -14,6 +14,13 @@ class HDCaseDialyzerLine(Model):
}
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"),
@ -25,6 +32,7 @@ class HDCaseDialyzerLine(Model):
'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', 'Nurse',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"

View File

@ -12,6 +12,7 @@ class HDCasePopupDlz(Model):
"exp_date": fields.Date("Expiry Date"),
"note": fields.Text("Note"),
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
'drop_old': fields.Boolean("Drop Old Dialyzer"),
}
def __get_hd_case_id(self,context={}):
@ -45,6 +46,7 @@ class HDCasePopupDlz(Model):
'membrane_type': membrane_type,
'max_use_time': max_use_time,
'product_id': product_id,
'drop_old': True,
}
print('res', res)
return res
@ -56,6 +58,7 @@ class HDCasePopupDlz(Model):
if hd_case:
context['is_wiz']=True
context['pop_id']=obj.id
context['drop_old']=obj.drop_old
res=hd_case.new_dialyzer(context=context)
print('res ', res)
return res