From 85c4c342d83c2d59c7129eaaa436eddc1da9c5b0 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Sun, 26 Jun 2022 18:30:54 +0530 Subject: [PATCH] fix: improve patches --- erpnext/patches.txt | 4 ++-- .../v13_0/remove_india_deprecation_warning.py | 10 ---------- ...how_india_localisation_deprecation_warning.py | 15 +++++++++++++++ ..._doctypes.py => remove_india_localisation.py} | 16 +++++++++++++--- 4 files changed, 30 insertions(+), 15 deletions(-) delete mode 100644 erpnext/patches/v13_0/remove_india_deprecation_warning.py create mode 100644 erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py rename erpnext/patches/v14_0/{delete_regional_india_doctypes.py => remove_india_localisation.py} (64%) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e9f39c91eb..aef80bca68 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -301,7 +301,7 @@ erpnext.patches.v13_0.delete_bank_reconciliation_detail erpnext.patches.v13_0.enable_provisional_accounting erpnext.patches.v13_0.non_profit_deprecation_warning erpnext.patches.v13_0.enable_ksa_vat_docs #1 -erpnext.patches.v13_0.remove_india_deprecation_warning +erpnext.patches.v13_0.show_india_localisation_deprecation_warning [post_model_sync] execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings') @@ -345,4 +345,4 @@ erpnext.patches.v13_0.set_payroll_entry_status erpnext.patches.v13_0.job_card_status_on_hold erpnext.patches.v14_0.migrate_gl_to_payment_ledger erpnext.patches.v14_0.crm_ux_cleanup -erpnext.patches.v14_0.delete_regional_india_doctypes +erpnext.patches.v14_0.remove_india_localisation diff --git a/erpnext/patches/v13_0/remove_india_deprecation_warning.py b/erpnext/patches/v13_0/remove_india_deprecation_warning.py deleted file mode 100644 index 006587f0d9..0000000000 --- a/erpnext/patches/v13_0/remove_india_deprecation_warning.py +++ /dev/null @@ -1,10 +0,0 @@ -import click - - -def execute(): - - click.secho( - "Regional India is moved to a separate app and will be removed from ERPNext in version-14.\n" - "Please install the app to continue using the module after upgrading to version-14: https://github.com/resilient-tech/india-compliance", - fg="yellow", - ) diff --git a/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py b/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py new file mode 100644 index 0000000000..1d76b25219 --- /dev/null +++ b/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py @@ -0,0 +1,15 @@ +import click +import frappe + + +def execute(): + if not frappe.db.exists("Company", {"country": "India"}): + return + + click.secho( + "India-specific regional features have been moved to a separate app" + " and will be removed from ERPNext in Version 14." + " Please install India Compliance after upgrading to Version 14:\n" + "https://github.com/resilient-tech/india-compliance", + fg="yellow", + ) diff --git a/erpnext/patches/v14_0/delete_regional_india_doctypes.py b/erpnext/patches/v14_0/remove_india_localisation.py similarity index 64% rename from erpnext/patches/v14_0/delete_regional_india_doctypes.py rename to erpnext/patches/v14_0/remove_india_localisation.py index f3e702057a..e7bfe6bc1f 100644 --- a/erpnext/patches/v14_0/delete_regional_india_doctypes.py +++ b/erpnext/patches/v14_0/remove_india_localisation.py @@ -34,10 +34,20 @@ def execute(): } for doctype, names in to_delete.items(): - frappe.delete_doc(doctype, names, ignore_missing=True, force=True) + frappe.delete_doc( + doctype, + names, + force=True, + ignore_permissions=True, + ignore_missing=True, + ) + + if not frappe.db.exists("Company", {"country": "India"}): + return click.secho( - "Regional India is moved to a separate app and is removed from ERPNext.\n" - "Please install the app to continue using the module: https://github.com/resilient-tech/india-compliance", + "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", )