diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index 7795d5f..f804f56 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -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 diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 48b8ea6..118bf86 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -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,