From 65f5b6a0a437d889045fc1c5986687439995e7c6 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 13 Feb 2025 17:23:57 +0530 Subject: [PATCH] fix: delete unused custom fields from web form --- .../v2_0/delete_unused_custom_fields.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lms/patches/v2_0/delete_unused_custom_fields.py b/lms/patches/v2_0/delete_unused_custom_fields.py index d49fe615..3fa6348d 100644 --- a/lms/patches/v2_0/delete_unused_custom_fields.py +++ b/lms/patches/v2_0/delete_unused_custom_fields.py @@ -1,13 +1,24 @@ import frappe + def execute(): - if "payments" not in frappe.get_installed_apps(): - web_form_custom_fields = frappe.get_all("Custom Field", { - "dt": "Web Form" - }, ["name", "fieldname"]) + if "payments" not in frappe.get_installed_apps(): + web_form_custom_fields = frappe.get_all( + "Custom Field", {"dt": "Web Form"}, ["name", "fieldname"] + ) - unused_fields = ["currency", "amount_field", "amount_based_on_field", "payment_button_help", "amount", "payments_cb", "payment_button_label", "payment_gateway", "payments_tab"] + unused_fields = [ + "currency", + "amount_field", + "amount_based_on_field", + "payment_button_help", + "amount", + "payments_cb", + "payment_button_label", + "payment_gateway", + "payments_tab", + ] - for field in web_form_custom_fields: - if field.fieldname in unused_fields: - frappe.delete_doc("Custom Field", field.name) \ No newline at end of file + for field in web_form_custom_fields: + if field.fieldname in unused_fields: + frappe.delete_doc("Custom Field", field.name)