conv_bal
watcha.h@almacom.co.th 2015-01-19 13:42:57 +07:00
parent 0af24d9bd1
commit 171f09fbb3
1 changed files with 16 additions and 2 deletions

View File

@ -29,7 +29,7 @@ class Dialyzer(Model):
"visit_id": fields.Many2One("clinic.visit","Visit"), "visit_id": fields.Many2One("clinic.visit","Visit"),
"hd_case_id": fields.Many2One("clinic.hd.case","HD Case"), "hd_case_id": fields.Many2One("clinic.hd.case","HD Case"),
"hd_cases": fields.One2Many("clinic.hd.case","dlz_id","HD Case"), #TODO funtion to get hd case "hd_cases": fields.One2Many("clinic.hd.case","dlz_id","HD Case"), #TODO funtion to get hd case
'department_id': fields.Many2One("clinic.department","Department"), 'department_id': fields.Many2One("clinic.department","Department",search=True),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -64,6 +64,19 @@ class Dialyzer(Model):
raise Exception("No Product with category 'Dialyzer'") raise Exception("No Product with category 'Dialyzer'")
return product_id return product_id
def _get_product_name(self,context={}):
categ_ids=get_model("product.categ").search([['name','=','Dialyzer']])
product_name=''
found=False
for prod in get_model("product").search_browse([]):
if found:
break
if prod.categ_id.id in categ_ids:
product_name=prod.name
found=True
break
return product_name
_defaults={ _defaults={
"state": "new", "state": "new",
"date": lambda *a: time.strftime("%Y-%m-%d"), "date": lambda *a: time.strftime("%Y-%m-%d"),
@ -72,6 +85,7 @@ class Dialyzer(Model):
"use_time": 0, "use_time": 0,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
'product_id': _get_product, 'product_id': _get_product,
'name': _get_product_name,
'dialyzer_type': 'low', 'dialyzer_type': 'low',
} }
_order="date desc,number desc" _order="date desc,number desc"
@ -169,7 +183,7 @@ class Dialyzer(Model):
'mode': 'form', 'mode': 'form',
'active_id': obj.id 'active_id': obj.id
}, },
'flash': 'Dializer %s is confirmed'%(obj.number), 'flash': 'Dialyzer %s is confirmed'%(number),
} }
print("Done!") print("Done!")