fix: unlink custom fields in patch
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 7309836..c3476f9 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -346,4 +346,4 @@
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 1d76b25..c993508 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 @@
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 7dc7b37..616c08f 100644
--- a/erpnext/patches/v14_0/remove_india_localisation.py
+++ b/erpnext/patches/v14_0/remove_india_localisation.py
@@ -3,6 +3,24 @@
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 @@
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": ""},
)