update item image in invoice if item exists
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 4e2cd26..1f74184 100644
--- a/erpnext/patches/v5_0/update_item_desc_in_invoice.py
+++ b/erpnext/patches/v5_0/update_item_desc_in_invoice.py
@@ -31,7 +31,9 @@
 				desc, image = extract_image_and_description(cstr(d.description))
 				
 				if not image:
-					image = item_details.get(d.item_code).image
+					item_detail = item_details.get(d.item_code)
+					if item_detail:
+						image = item_detail.image
 
 			frappe.db.sql("""update `tab{0}` set description = %s, image = %s
 				where name = %s """.format(dt), (desc, image, d.name))