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

diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index d6db40d..74dfa05 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -19,7 +19,7 @@
 		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 @@
 	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 @@
 	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"""