From fc4eca5cc76ea9d9acd0267e243b736f5b5bca2a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 11 Dec 2015 11:47:05 +0530 Subject: [PATCH] [fix] Website Image validation --- erpnext/stock/doctype/item/item.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 6bdafcf385..489b1bda41 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -89,21 +89,23 @@ class Item(WebsiteGenerator): auto_set_website_image = True self.website_image = self.image - file = frappe.db.get_value("File", filters={ - "file_url": self.website_image, - "attached_to_doctype": self.doctype, - "attached_to_name": self.name - }, fieldname=["name", "is_private"], as_dict=True) + if self.website_image: + file = frappe.db.get_value("File", filters={ + "file_url": self.website_image, + "attached_to_doctype": self.doctype, + "attached_to_name": self.name + }, fieldname=["name", "is_private"], as_dict=True) - if not file: - self.website_image = None - if not auto_set_website_image: - frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found").format(self.website_image, self.name)) + if not file: + if not auto_set_website_image: + frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found") + .format(self.website_image, self.name)) + self.website_image = None - elif file.is_private: - self.website_image = None - if not auto_set_website_image: - frappe.msgprint(_("Website Image should be a public file or website URL")) + elif file.is_private: + self.website_image = None + if not auto_set_website_image: + frappe.msgprint(_("Website Image should be a public file or website URL")) def make_thumbnail(self): """Make a thumbnail of `website_image`"""