diff --git a/erpnext/patches/v12_0/update_is_cancelled_field.py b/erpnext/patches/v12_0/update_is_cancelled_field.py index 989ea380e9a..a3bd4fd6918 100644 --- a/erpnext/patches/v12_0/update_is_cancelled_field.py +++ b/erpnext/patches/v12_0/update_is_cancelled_field.py @@ -4,20 +4,18 @@ import frappe def execute(): #handle type casting for is_cancelled field + module_doctypes = ( + ('stock', 'Stock Ledger Entry'), + ('stock', 'Serial No'), + ('accounts', 'GL Entry') + ) - for doc_mapper in (('stock','Stock Ledger Entry'), - ('stock','Serial No'), - ('accounts','GL Entry')): - try: - module = doc_mapper[0] - doctype = doc_mapper[1] - + for module, doctype in module_doctypes: + if frappe.db.has_column(doctype, "is_cancelled"): frappe.db.sql('''UPDATE `tab{doctype}` SET is_cancelled = CASE WHEN is_cancelled = 'No' THEN 0 WHEN is_cancelled = 'Yes' THEN 1 ELSE 0 END'''.format(doctype=doctype)) - frappe.reload_doc(module, "doctype", frappe.scrub(doctype)) - except Exception: - pass \ No newline at end of file + frappe.reload_doc(module, "doctype", frappe.scrub(doctype))