[thumbnail] remove attachment if fails

This commit is contained in:
Rushabh Mehta 2015-11-05 10:49:42 +05:30
parent b42f3e34ef
commit c541b87bb9

View File

@ -85,6 +85,8 @@ class Item(WebsiteGenerator):
def make_thumbnail(self): def make_thumbnail(self):
"""Make a thumbnail of `website_image`""" """Make a thumbnail of `website_image`"""
import requests.exceptions
if not self.is_new() and self.website_image != frappe.db.get_value(self.doctype, self.name, "website_image"): if not self.is_new() and self.website_image != frappe.db.get_value(self.doctype, self.name, "website_image"):
self.thumbnail = None self.thumbnail = None
@ -102,8 +104,12 @@ class Item(WebsiteGenerator):
# cleanup # cleanup
frappe.local.message_log.pop() frappe.local.message_log.pop()
except requests.exceptions.HTTPError:
frappe.msgprint(_("Warning: Invalid Attachment {0}").format(self.website_image))
self.website_image = None
# for CSV import # for CSV import
if not file_doc: if self.website_image and not file_doc:
try: try:
file_doc = frappe.get_doc({ file_doc = frappe.get_doc({
"doctype": "File", "doctype": "File",