2017-08-28 12:47:36 +00:00
|
|
|
from __future__ import print_function
|
2015-10-07 09:00:19 +00:00
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
|
|
|
frappe.reload_doctype("File")
|
|
|
|
frappe.reload_doctype("Item")
|
2015-10-20 13:04:21 +00:00
|
|
|
for item in frappe.get_all("Item", fields=("name", "website_image", "thumbnail")):
|
|
|
|
if item.website_image and not item.thumbnail:
|
2015-10-07 09:00:19 +00:00
|
|
|
item_doc = frappe.get_doc("Item", item.name)
|
|
|
|
try:
|
|
|
|
item_doc.make_thumbnail()
|
|
|
|
if item_doc.thumbnail:
|
2015-10-14 10:03:14 +00:00
|
|
|
item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False)
|
2015-10-07 09:00:19 +00:00
|
|
|
except Exception:
|
2017-08-28 12:47:36 +00:00
|
|
|
print("Unable to make thumbnail for {0}".format(item.website_image.encode("utf-8")))
|