diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 5bfd34e869..74bd37a39c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -436,4 +436,5 @@ erpnext.patches.v8_7.add_more_gst_fields erpnext.patches.v8_7.fix_purchase_receipt_status erpnext.patches.v8_6.rename_bom_update_tool erpnext.patches.v8_9.set_print_zero_amount_taxes -erpnext.patches.v8_9.set_default_customer_group \ No newline at end of file +erpnext.patches.v8_9.set_default_customer_group +erpnext.patches.v8_9.delete_gst_doctypes_for_outside_india_accounts \ No newline at end of file diff --git a/erpnext/patches/v8_1/setup_gst_india.py b/erpnext/patches/v8_1/setup_gst_india.py index 566069369c..f329916ed5 100644 --- a/erpnext/patches/v8_1/setup_gst_india.py +++ b/erpnext/patches/v8_1/setup_gst_india.py @@ -2,21 +2,25 @@ import frappe from frappe.email import sendmail_to_system_managers def execute(): - frappe.reload_doc('regional', 'doctype', 'gst_settings') - frappe.reload_doc('regional', 'doctype', 'gst_hsn_code') frappe.reload_doc('stock', 'doctype', 'item') frappe.reload_doc("stock", "doctype", "customs_tariff_number") + company = frappe.get_all('Company', filters = {'country': 'India'}) + if not company: + return + + frappe.reload_doc('regional', 'doctype', 'gst_settings') + frappe.reload_doc('regional', 'doctype', 'gst_hsn_code') + for report_name in ('GST Sales Register', 'GST Purchase Register', 'GST Itemised Sales Register', 'GST Itemised Purchase Register'): frappe.reload_doc('regional', 'report', frappe.scrub(report_name)) - if frappe.db.get_single_value('System Settings', 'country')=='India': - from erpnext.regional.india.setup import setup - delete_custom_field_tax_id_if_exists() - setup(patch=True) - send_gst_update_email() + from erpnext.regional.india.setup import setup + delete_custom_field_tax_id_if_exists() + setup(patch=True) + send_gst_update_email() def delete_custom_field_tax_id_if_exists(): for field in frappe.db.sql_list("""select name from `tabCustom Field` where fieldname='tax_id' diff --git a/erpnext/patches/v8_9/delete_gst_doctypes_for_outside_india_accounts.py b/erpnext/patches/v8_9/delete_gst_doctypes_for_outside_india_accounts.py new file mode 100644 index 0000000000..2b4ac58a67 --- /dev/null +++ b/erpnext/patches/v8_9/delete_gst_doctypes_for_outside_india_accounts.py @@ -0,0 +1,13 @@ +import frappe + +def execute(): + company = frappe.get_all('Company', filters = {'country': 'India'}) + if not company: + if frappe.db.exists("DocType", "GST Settings"): + frappe.delete_doc("DocType", "GST Settings") + frappe.delete_doc("DocType", "GST HSN Code") + + for report_name in ('GST Sales Register', 'GST Purchase Register', + 'GST Itemised Sales Register', 'GST Itemised Purchase Register'): + + frappe.delete_doc('Report', report_name) \ No newline at end of file