brotherton-erpnext/erpnext/patches/v6_4/make_image_thumbnail.py

15 lines
523 B
Python
Raw Normal View History

import frappe
def execute():
frappe.reload_doctype("File")
frappe.reload_doctype("Item")
2015-10-20 18:34:21 +05:30
for item in frappe.get_all("Item", fields=("name", "website_image", "thumbnail")):
if item.website_image and not item.thumbnail:
item_doc = frappe.get_doc("Item", item.name)
try:
item_doc.make_thumbnail()
if item_doc.thumbnail:
2015-10-14 15:33:14 +05:30
item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False)
except Exception:
2015-10-19 17:33:16 +05:30
print "Unable to make thumbnail for {0}".format(item.website_image.encode("utf-8"))