set default warehouse instead of product bundle's warehouse for packed_items in delivery note (#13398)

This commit is contained in:
Shreya Shah 2018-03-27 11:32:10 +05:30 committed by Nabin Hait
parent 85f63a3866
commit ba4f32be5c

View File

@ -19,7 +19,7 @@ def get_product_bundle_items(item_code):
where t2.new_item_code=%s and t1.parent = t2.name order by t1.idx""", item_code, as_dict=1)
def get_packing_item_details(item):
return frappe.db.sql("""select item_name, description, stock_uom from `tabItem`
return frappe.db.sql("""select item_name, description, stock_uom, default_warehouse from `tabItem`
where name = %s""", item, as_dict = 1)[0]
def get_bin_qty(item, warehouse):
@ -28,7 +28,6 @@ def get_bin_qty(item, warehouse):
return det and det[0] or frappe._dict()
def update_packing_list_item(doc, packing_item_code, qty, main_item_row, description):
bin = get_bin_qty(packing_item_code, main_item_row.warehouse)
item = get_packing_item_details(packing_item_code)
# check if exists
@ -48,15 +47,16 @@ def update_packing_list_item(doc, packing_item_code, qty, main_item_row, descrip
pi.description = item.description
pi.uom = item.stock_uom
pi.qty = flt(qty)
pi.actual_qty = flt(bin.get("actual_qty"))
pi.projected_qty = flt(bin.get("projected_qty"))
pi.description = description
if not pi.warehouse:
pi.warehouse = main_item_row.warehouse
pi.warehouse = item.default_warehouse or main_item_row.warehouse
if not pi.batch_no:
pi.batch_no = cstr(main_item_row.get("batch_no"))
if not pi.target_warehouse:
pi.target_warehouse = main_item_row.get("target_warehouse")
bin = get_bin_qty(packing_item_code, pi.warehouse)
pi.actual_qty = flt(bin.get("actual_qty"))
pi.projected_qty = flt(bin.get("projected_qty"))
def make_packing_list(doc):
"""make packing list for Product Bundle item"""