diff --git a/erpnext/patches/dokos/v1_0/remove_non_profit_domain.py b/erpnext/patches/dokos/v1_0/remove_non_profit_domain.py index 17d5d99e06df8fa43baff6a49e6d6046c5dc25b5..9e7b716c18aac211ce574b094a296023c30b6558 100644 --- a/erpnext/patches/dokos/v1_0/remove_non_profit_domain.py +++ b/erpnext/patches/dokos/v1_0/remove_non_profit_domain.py @@ -8,32 +8,16 @@ def execute(): roles = ["Non Profit Manager", "Non Profit Member", "Non Profit Portal User"] doctypes = [x["name"] for x in frappe.get_all("DocType", filters={"module": "Non Profit"})] - frappe.db.sql( - """ - DELETE - FROM - `tabHas Role` - WHERE - role in ({0}) - """.format( - ",".join(["%s"] * len(roles)) - ), - tuple(roles), - ) + try: + frappe.db.delete("Has Role", {"role": ("in", roles)}) + except Exception as e: + print(e) # Standard portal items - frappe.db.sql( - """ - DELETE - FROM - `tabPortal Menu Item` - WHERE - reference_doctype in ({0}) - """.format( - ",".join(["%s"] * len(doctypes)) - ), - tuple(doctypes), - ) + try: + frappe.db.delete("Portal Menu Item", {"reference_doctype": ("in", doctypes)}) + except Exception as e: + print(e) # Delete DocTypes, Pages, Reports, Roles, Domain and Custom Fields elements = [ @@ -43,9 +27,7 @@ def execute(): }, { "document": "Report", - "items": [ - x["name"] for x in frappe.get_all("Report", filters={"ref_doctype": ["in", doctypes]}) - ], + "items": [x["name"] for x in frappe.get_all("Report", filters={"ref_doctype": ["in", doctypes]})], }, {"document": "DocType", "items": doctypes}, {"document": "Role", "items": roles}, @@ -63,15 +45,7 @@ def execute(): # Delete Desktop Icons desktop_icons = ["Non Profit", "Member", "Donor", "Volunteer", "Grant Application"] - frappe.db.sql( - """ - DELETE - FROM - `tabDesktop Icon` - WHERE - module_name in ({0}) - """.format( - ",".join(["%s"] * len(desktop_icons)) - ), - tuple(desktop_icons), - ) + try: + frappe.db.delete("Desktop Icon", {"module_name": ("in", desktop_icons)}) + except Exception as e: + print(e)