From 7e5cac82f21528f8498fd694dff43af04d1cdc90 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Fri, 19 Aug 2016 16:33:19 +0700 Subject: [PATCH] when create picking after click button claim expense if product have not parent code then should use that one --- netforce_clinic/models/hd_case.py | 35 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 0c6b9f5..c63da22 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -814,7 +814,7 @@ class HDCase(Model): if no_lines: return prod_ids=context.get('prod_ids') or [] - prod_exist_ids=[] + duplicate_ids=[] for line in obj.lines: if line.state!='draft': continue @@ -825,31 +825,28 @@ class HDCase(Model): continue if not st.dlz_picking_auto and prod.categ_id.code=='DLZ': continue - # check orginal product - prod_code=prod.code.split("-")[0] + # looking for master product code if not use the original + ################## this concept we use + # this concept we use for create GI which only 1 product because + # 1000 + # 1000-SSO + # 1000-UC + # 1000-.... + # we will combine all this to product code 1000 if patient.type_id.main_product: - if len(prod_code)>1: - prods=get_model('product').search_browse(['code','=',prod_code]) + master_prod_code=prod.code.split("-")[0] + test_ids=get_model('product').search(['code','ilike','%'+master_prod_code+"%"]) + if len(test_ids)>1: + prods=get_model('product').search_browse(['code','=',master_prod_code]) if not context.get('migrate'): if not prods: - raise Exception("Can not create goods issue: product code %s is not found!"%prod_code) + raise Exception("Can not create goods issue: product code %s is not found!"%master_prod_code) prod=prods[0] else: continue - if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids: + if prod_ids and prod.id not in prod_ids or prod.id in duplicate_ids: continue - prod_exist_ids.append(prod.id) - dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id) - if dpt_prods: - wh_loc_id=dpt_prods.get('wh_loc_id') - cust_loc_id=dpt_prods.get('cust_loc_id') - if not wh_loc_id: - wh_loc_id=prod.location_id.id - if wh_loc_id: - res=get_model("stock.location").search([["type","=","internal"]]) - if not res: - raise Exception("Warehouse not found") - wh_loc_id=res[0] + duplicate_ids.append(prod.id) line_vals={ "product_id": prod.id, "qty": line.qty,