* chore: patch fixes (cherry picked from commit8b5b146f6d) # Conflicts: # erpnext/patches/v13_0/make_homepage_products_website_items.py * fix: remove desktop icons while deleting sales reports (cherry picked from commit5f72026cb9) * refactor: dont ignore dangerous exceptions in patches (cherry picked from commit0aa1ea8aeb) * fix: make patch kinda idempotent with previous query rerunning would've caused all values to become 0. * chore: conflicts * fix: check type before patching Co-authored-by: Saurabh <saurabh6790@gmail.com> Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
@@ -2,14 +2,28 @@ import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
try:
|
||||
frappe.db.sql("UPDATE `tabStock Ledger Entry` SET is_cancelled = 0 where is_cancelled in ('', NULL, 'No')")
|
||||
frappe.db.sql("UPDATE `tabSerial No` SET is_cancelled = 0 where is_cancelled in ('', NULL, 'No')")
|
||||
#handle type casting for is_cancelled field
|
||||
module_doctypes = (
|
||||
('stock', 'Stock Ledger Entry'),
|
||||
('stock', 'Serial No'),
|
||||
('accounts', 'GL Entry')
|
||||
)
|
||||
|
||||
frappe.db.sql("UPDATE `tabStock Ledger Entry` SET is_cancelled = 1 where is_cancelled = 'Yes'")
|
||||
frappe.db.sql("UPDATE `tabSerial No` SET is_cancelled = 1 where is_cancelled = 'Yes'")
|
||||
for module, doctype in module_doctypes:
|
||||
if (not frappe.db.has_column(doctype, "is_cancelled")
|
||||
or frappe.db.get_column_type(doctype, "is_cancelled").lower() == "int(1)"
|
||||
):
|
||||
continue
|
||||
|
||||
frappe.reload_doc("stock", "doctype", "stock_ledger_entry")
|
||||
frappe.reload_doc("stock", "doctype", "serial_no")
|
||||
except Exception:
|
||||
pass
|
||||
frappe.db.sql("""
|
||||
UPDATE `tab{doctype}`
|
||||
SET is_cancelled = 0
|
||||
where is_cancelled in ('', NULL, 'No')"""
|
||||
.format(doctype=doctype))
|
||||
frappe.db.sql("""
|
||||
UPDATE `tab{doctype}`
|
||||
SET is_cancelled = 1
|
||||
where is_cancelled = 'Yes'"""
|
||||
.format(doctype=doctype))
|
||||
|
||||
frappe.reload_doc(module, "doctype", frappe.scrub(doctype))
|
||||
|
||||
Reference in New Issue
Block a user