Merge pull request #3559 from nabinhait/develop

Fixes
diff --git a/erpnext/change_log/v5_1_0.md b/erpnext/change_log/v5/v5_1_0.md
similarity index 81%
rename from erpnext/change_log/v5_1_0.md
rename to erpnext/change_log/v5/v5_1_0.md
index 9a35002..3ed2227 100644
--- a/erpnext/change_log/v5_1_0.md
+++ b/erpnext/change_log/v5/v5_1_0.md
@@ -1,4 +1,4 @@
-- Item variants is now manageable via dedicated tool **Manage Variants**. To learn about it, check https://manual.erpnext.com/contents/stock/item/item-variants
+- Item variants is now manageable via dedicated tool **Manage Variants**. To learn about it, check [Manual Page for Item variants](https://manual.erpnext.com/contents/stock/item/item-variants)
 - Against account in General Ledger will show Party instead of Account (which is not useful)
 - Print format for recurring documents can be set by the users
 - Recurring documents won't be created for Stopped Sales / Purchase Orders.
diff --git a/erpnext/patches/v5_0/update_item_desc_in_invoice.py b/erpnext/patches/v5_0/update_item_desc_in_invoice.py
index b7a071c..4e2cd26 100644
--- a/erpnext/patches/v5_0/update_item_desc_in_invoice.py
+++ b/erpnext/patches/v5_0/update_item_desc_in_invoice.py
@@ -20,12 +20,11 @@
 	for dt in dt_list:
 		frappe.reload_doctype(dt)
 		records = frappe.db.sql("""select name, item_code, description from `tab{0}`
-			where description is not null """.format(dt), as_dict=1)
+			where ifnull(item_code, '') != '' and description is not null """.format(dt), as_dict=1)
 
 		count = 1
 		for d in records:
-			if d.item_code and item_details.get(d.item_code) \
-					and cstr(d.description) == item_details.get(d.item_code).description:
+			if item_details.get(d.item_code) and cstr(d.description) == item_details.get(d.item_code).description:
 				desc = item_details.get(d.item_code).description
 				image = item_details.get(d.item_code).image
 			else: