* Use Python 3 style print function * Use 'Exception as e' instead of 'Exception, e' * Unpack tuple arguments explicitly in instead of relying on auto unpacking * Use consistent indentation * Use 0 if stock_frozen_upto_days is None
		
			
				
	
	
		
			16 lines
		
	
	
		
			562 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			562 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from __future__ import print_function
 | |
| import frappe
 | |
| 
 | |
| def execute():
 | |
| 	frappe.reload_doctype("File")
 | |
| 	frappe.reload_doctype("Item")
 | |
| 	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:
 | |
| 					item_doc.db_set("thumbnail", item_doc.thumbnail, update_modified=False)
 | |
| 			except Exception:
 | |
| 				print("Unable to make thumbnail for {0}".format(item.website_image.encode("utf-8")))
 |