Merge branch 'develop'
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index e366e5b..f4a63fa 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
 from __future__ import unicode_literals
-__version__ = '6.5.0'
+__version__ = '6.5.1'
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 8280154..fed054c 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -29,7 +29,7 @@
 """
 app_icon = "icon-th"
 app_color = "#e74c3c"
-app_version = "6.5.0"
+app_version = "6.5.1"
 github_link = "https://github.com/frappe/erpnext"
 
 error_report_email = "support@erpnext.com"
diff --git a/erpnext/patches/v6_4/make_image_thumbnail.py b/erpnext/patches/v6_4/make_image_thumbnail.py
index 1daaede..36bdcfc 100644
--- a/erpnext/patches/v6_4/make_image_thumbnail.py
+++ b/erpnext/patches/v6_4/make_image_thumbnail.py
@@ -11,4 +11,4 @@
 				if item_doc.thumbnail:
 					item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False)
 			except Exception:
-				print "Unable to make thumbnail for {0}".format(item.website_image)
+				print "Unable to make thumbnail for {0}".format(item.website_image.encode("utf-8"))
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index 760d63b..07308e6 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -16,7 +16,8 @@
 from erpnext.stock.doctype.stock_entry.test_stock_entry \
 	import make_stock_entry, make_serialized_item, get_qty_after_transaction
 from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, SerialNoWarehouseError
-from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import create_stock_reconciliation
+from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation \
+	import create_stock_reconciliation, set_valuation_method
 
 class TestDeliveryNote(unittest.TestCase):
 	def test_over_billing_against_dn(self):
@@ -57,7 +58,7 @@
 	def test_delivery_note_gl_entry(self):
 		set_perpetual_inventory()
 		self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
-		frappe.db.set_value("Item", "_Test Item", "valuation_method", "FIFO")
+		set_valuation_method("_Test Item", "FIFO")
 
 		make_stock_entry(target="_Test Warehouse - _TC", qty=5, basic_rate=100)
 
@@ -326,14 +327,16 @@
 
 	def test_delivery_of_bundled_items_to_target_warehouse(self):
 		set_perpetual_inventory()
-		frappe.db.set_value("Item", "_Test Item", "valuation_method", "FIFO")
+		
+		set_valuation_method("_Test Item", "FIFO")
+		set_valuation_method("_Test Item Home Desktop 100", "FIFO")
 
 		for warehouse in ("_Test Warehouse - _TC", "_Test Warehouse 1 - _TC"):
 			create_stock_reconciliation(item_code="_Test Item", target=warehouse,
-				qty=50, rate=100)
+				qty=100, rate=100)
 			create_stock_reconciliation(item_code="_Test Item Home Desktop 100",
-				target=warehouse, qty=50, rate=100)
-
+				target=warehouse, qty=100, rate=100)
+				
 		opening_qty_test_warehouse_1 = get_qty_after_transaction(warehouse="_Test Warehouse 1 - _TC")
 
 		dn = create_delivery_note(item_code="_Test Product Bundle Item",
@@ -343,19 +346,36 @@
 
 		# qty after delivery
 		actual_qty = get_qty_after_transaction(warehouse="_Test Warehouse - _TC")
-		self.assertEquals(actual_qty, 25)
+		self.assertEquals(actual_qty, 75)
 
 		actual_qty = get_qty_after_transaction(warehouse="_Test Warehouse 1 - _TC")
 		self.assertEquals(actual_qty, opening_qty_test_warehouse_1 + 25)
 
 		# stock value diff for source warehouse
-		stock_value_difference = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Delivery Note",
-			"voucher_no": dn.name, "item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse - _TC"},
+		# for "_Test Item"
+		stock_value_difference = frappe.db.get_value("Stock Ledger Entry", 
+			{"voucher_type": "Delivery Note", "voucher_no": dn.name, 
+				"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"},
 			"stock_value_difference")
 
 		# stock value diff for target warehouse
-		stock_value_difference1 = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Delivery Note",
-			"voucher_no": dn.name, "item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse 1 - _TC"},
+		stock_value_difference1 = frappe.db.get_value("Stock Ledger Entry", 
+			{"voucher_type": "Delivery Note", "voucher_no": dn.name, 
+				"item_code": "_Test Item", "warehouse": "_Test Warehouse 1 - _TC"},
+			"stock_value_difference")
+
+		self.assertEquals(abs(stock_value_difference), stock_value_difference1)
+
+		# for "_Test Item Home Desktop 100"
+		stock_value_difference = frappe.db.get_value("Stock Ledger Entry", 
+			{"voucher_type": "Delivery Note", "voucher_no": dn.name, 
+				"item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse - _TC"},
+			"stock_value_difference")
+
+		# stock value diff for target warehouse
+		stock_value_difference1 = frappe.db.get_value("Stock Ledger Entry", 
+			{"voucher_type": "Delivery Note", "voucher_no": dn.name, 
+				"item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse 1 - _TC"},
 			"stock_value_difference")
 
 		self.assertEquals(abs(stock_value_difference), stock_value_difference1)
diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
index cfaa499..947a093 100644
--- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
@@ -36,8 +36,8 @@
 		]
 
 		for d in input_data:
-			repost_stock_as_per_valuation_method(valuation_method)
-
+			set_valuation_method("_Test Item", valuation_method)
+			
 			last_sle = get_previous_sle({
 				"item_code": "_Test Item",
 				"warehouse": "_Test Warehouse - _TC",
@@ -114,11 +114,13 @@
 		pass
 	return sr
 
-def repost_stock_as_per_valuation_method(valuation_method):
-	frappe.db.set_value("Item", "_Test Item", "valuation_method", valuation_method)
-	update_entries_after({
-		"item_code": "_Test Item",
-		"warehouse": "_Test Warehouse - _TC",
-	}, allow_negative_stock=1)
+def set_valuation_method(item_code, valuation_method):
+	frappe.db.set_value("Item", item_code, "valuation_method", valuation_method)
+
+	for warehouse in frappe.get_all("Warehouse", filters={"company": "_Test Company"}):
+		update_entries_after({
+			"item_code": item_code,
+			"warehouse": warehouse.name
+		}, allow_negative_stock=1)
 
 test_dependencies = ["Item", "Warehouse"]
diff --git a/setup.py b/setup.py
index d3f1281..0241b70 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages
 
-version = "6.5.0"
+version = "6.5.1"
 
 with open("requirements.txt", "r") as f:
 	install_requires = f.readlines()