brotherton-erpnext/erpnext/patches/v6_4/make_image_thumbnail.py
Rushabh Mehta fb73151da6 [fixes]
2015-10-14 16:22:01 +05:30

15 lines
471 B
Python

import frappe
def execute():
frappe.reload_doctype("File")
frappe.reload_doctype("Item")
for item in frappe.get_all("Item", fields=("name", "website_image")):
if item.website_image:
item_doc = frappe.get_doc("Item", item.name)
try:
item_doc.make_thumbnail()
if item_doc.thumbnail:
item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False)
except Exception:
print "Unable to make thumbnail for {0}".format(item.website_image)