# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt import frappe from frappe.website.utils import find_first_image from frappe.utils import cstr import re def execute(): item_details = frappe._dict() for d in frappe.db.sql("select name, description_html, description from `tabItem`", as_dict=1): description = cstr(d.description_html).strip() or cstr(d.description).strip() image_url, new_desc = extract_image_and_description(description) item_details.setdefault(d.name, frappe._dict({ "old_description": description, "new_description": new_desc, "image_url": image_url })) dt_list= ["Purchase Order Item","Supplier Quotation Item", "BOM", "BOM Explosion Item" , \ "BOM Item", "Opportunity Item" , "Quotation Item" , "Sales Order Item" , "Delivery Note Item" , \ "Material Request Item" , "Purchase Receipt Item" , "Stock Entry Detail"] for dt in dt_list: frappe.reload_doctype(dt) records = frappe.db.sql("""select name, `{0}` as item_code, description from `tab{1}` where description is not null and image is null and description like '%%]+\>", "", data) return image_url, desc