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,