From 70c4117c22df5ab3efda0be842452cabc2f9aab9 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Thu, 14 Jul 2022 15:02:17 +0530 Subject: [PATCH] fix: unlink custom fields in patch --- erpnext/patches.txt | 2 +- ..._india_localisation_deprecation_warning.py | 5 +++- .../v14_0/remove_india_localisation.py | 30 ++++++++++++++----- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 73098367c5..c3476f9b8f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -346,4 +346,4 @@ erpnext.patches.v13_0.job_card_status_on_hold erpnext.patches.v14_0.copy_is_subcontracted_value_to_is_old_subcontracting_flow erpnext.patches.v14_0.migrate_gl_to_payment_ledger erpnext.patches.v14_0.crm_ux_cleanup -erpnext.patches.v14_0.remove_india_localisation # 07-07-2022 +erpnext.patches.v14_0.remove_india_localisation # 14-07-2022 diff --git a/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py b/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py index 1d76b25219..c9935085fa 100644 --- a/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py +++ b/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py @@ -3,7 +3,10 @@ import frappe def execute(): - if not frappe.db.exists("Company", {"country": "India"}): + if ( + not frappe.db.exists("Company", {"country": "India"}) + or "india_compliance" in frappe.get_installed_apps() + ): return click.secho( diff --git a/erpnext/patches/v14_0/remove_india_localisation.py b/erpnext/patches/v14_0/remove_india_localisation.py index 7dc7b3773f..616c08f886 100644 --- a/erpnext/patches/v14_0/remove_india_localisation.py +++ b/erpnext/patches/v14_0/remove_india_localisation.py @@ -3,6 +3,24 @@ import frappe def execute(): + if "india_compliance" in frappe.get_installed_apps(): + return + + delete_docs() + unlink_custom_fields() + + if not frappe.db.exists("Company", {"country": "India"}): + return + + click.secho( + "India-specific regional features have been moved to a separate app." + " Please install India Compliance to continue using these features:" + " https://github.com/resilient-tech/india-compliance", + fg="yellow", + ) + + +def delete_docs(): to_delete = { "DocType": [ "C-Form", @@ -44,12 +62,10 @@ def execute(): ignore_missing=True, ) - if not frappe.db.exists("Company", {"country": "India"}): - return - click.secho( - "India-specific regional features have been moved to a separate app." - " Please install India Compliance to continue using these features:" - " https://github.com/resilient-tech/india-compliance", - fg="yellow", +def unlink_custom_fields(): + frappe.db.set_value( + "Custom Field", + {"dt": "Item", "fieldname": "gst_hsn_code"}, + {"fieldtype": "Data", "options": ""}, )