From ac8014e24c761f3be302bad1f4d14c4a65c8f78f Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 19 Oct 2021 18:50:44 +0530 Subject: [PATCH] fix: Check if thumbnail column exists in case of table trimming --- erpnext/patches/v13_0/create_website_items.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v13_0/create_website_items.py b/erpnext/patches/v13_0/create_website_items.py index 51be13f554a..a1e14e48a13 100644 --- a/erpnext/patches/v13_0/create_website_items.py +++ b/erpnext/patches/v13_0/create_website_items.py @@ -16,6 +16,7 @@ def execute(): web_fields_to_map = ["route", "slideshow", "website_image_alt", "website_warehouse", "web_long_description", "website_content", "thumbnail"] + # get all valid columns (fields) from Item master DB schema item_table_fields = frappe.db.sql("desc `tabItem`", as_dict=1) item_table_fields = [d.get('Field') for d in item_table_fields] @@ -45,7 +46,10 @@ def execute(): count = 0 for item in items: - if frappe.db.exists("Website Item", {"item_code": item.item_code}): + web_item_exists = frappe.db.exists("Website Item", {"item_code": item.item_code}) + thumbnail_column_exists = "thumbnail" in item_table_fields + + if web_item_exists and thumbnail_column_exists: # if website item already exists check for empty thumbnail # if empty, fetch thumbnail from Item master web_item_doc = frappe.db.get_values(