refactor: dont ignore dangerous exceptions in patches

This commit is contained in:
Ankush Menat
2022-01-21 16:25:03 +05:30
parent bf4e0c3b7d
commit 0aa1ea8aeb

View File

@@ -4,20 +4,18 @@ import frappe
def execute(): def execute():
#handle type casting for is_cancelled field #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'), for module, doctype in module_doctypes:
('stock','Serial No'), if frappe.db.has_column(doctype, "is_cancelled"):
('accounts','GL Entry')):
try:
module = doc_mapper[0]
doctype = doc_mapper[1]
frappe.db.sql('''UPDATE `tab{doctype}` SET is_cancelled = CASE frappe.db.sql('''UPDATE `tab{doctype}` SET is_cancelled = CASE
WHEN is_cancelled = 'No' THEN 0 WHEN is_cancelled = 'No' THEN 0
WHEN is_cancelled = 'Yes' THEN 1 WHEN is_cancelled = 'Yes' THEN 1
ELSE 0 ELSE 0
END'''.format(doctype=doctype)) END'''.format(doctype=doctype))
frappe.reload_doc(module, "doctype", frappe.scrub(doctype)) frappe.reload_doc(module, "doctype", frappe.scrub(doctype))
except Exception:
pass