dlz & hd case

conv_bal
watcha.h 2014-10-26 09:23:27 +07:00
parent d328ee0a81
commit c6e7131b27
2 changed files with 12 additions and 8 deletions

View File

@ -52,14 +52,14 @@ class Dialyzer(Model):
def _get_product(self,context={}):
categ_ids=get_model("product.categ").search([['name','=','Dialyzer']])
product_id=None
stop=False
found=False
for prod in get_model("product").search_browse([]):
if stop:
if found:
break
for categ in prod.categs:
if categ.id in categ_ids:
product_id=prod.id
stop=True
found=True
break
return product_id

View File

@ -127,7 +127,7 @@ class HDCase(Model):
})
raise Exception("%s is expired"%dialyzer.number)
use_time+=1
line["description"]=dialyzer.description or ""
line["description"]=dialyzer.description or dialyzer.product_id.name or ""
line["use_time"]=use_time
line["max_use_time"]=dialyzer.max_use_time
line["member_type"]=dialyzer.member_type
@ -623,9 +623,13 @@ class HDCase(Model):
def new_dialyzer(self,ids,context={}):
obj=self.browse(ids)[0]
dlz_id=get_model('clinic.dialyzer').create({
'patient_id': obj.patient_id.id,
})
dlz_vals=get_model("clinic.dialyzer").default_get()
dlz_vals['patient_id']=obj.patient_id.id
dlz_vals['company_id']=dlz_vals['company_id'][0]
product_name=dlz_vals['product_id'][1]
dlz_vals['product_id']=dlz_vals['product_id'][0]
dlz_id=get_model('clinic.dialyzer').create(dlz_vals)
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
dialyzer.confirm()
vals={
@ -634,7 +638,7 @@ class HDCase(Model):
}
vals['dialyzers'].append(('create',{
'dialyzer_id': dlz_id,
'description': dialyzer.description or "",
'description': dialyzer.description or product_name,
'use_time': 1,
'max_use_time': dialyzer.max_use_time,
'member_type': dialyzer.member_type,