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():
#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
frappe.reload_doc(module, "doctype", frappe.scrub(doctype))