From 4fd1cebf9565ed037d6092966b32d45a7dbfd0ee Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 6 Sep 2018 18:53:31 +0530 Subject: [PATCH] fix(patch): Delete all documents from Hub Node module --- erpnext/patches.txt | 2 +- erpnext/patches/v10_0/delete_hub_documents.py | 17 +++++++++++++++++ .../v10_0/setup_vat_for_uae_and_saudi_arabia.py | 1 - erpnext/patches/v8_1/setup_gst_india.py | 1 - 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 erpnext/patches/v10_0/delete_hub_documents.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e5644a3818..313f3789fd 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -505,4 +505,4 @@ erpnext.patches.v10_0.update_status_in_purchase_receipt erpnext.patches.v10_0.update_address_template_for_india erpnext.patches.v10_0.set_discount_amount erpnext.patches.v10_0.recalculate_gross_margin_for_project -execute:frappe.delete_doc("Page", "hub", ignore_missing=True) +erpnext.patches.v10_0.delete_hub_documents \ No newline at end of file diff --git a/erpnext/patches/v10_0/delete_hub_documents.py b/erpnext/patches/v10_0/delete_hub_documents.py new file mode 100644 index 0000000000..293969b29b --- /dev/null +++ b/erpnext/patches/v10_0/delete_hub_documents.py @@ -0,0 +1,17 @@ + +import frappe +from frappe.model.utils.rename_field import rename_field + +def execute(): + for dt, dn in (("Page", "Hub"), ("DocType", "Hub Settings"), ("DocType", "Hub Category")): + frappe.delete_doc(dt, dn, ignore_missing=True) + + data_migration_plans = frappe.get_all("Data Migration Plan", filters={"module": 'Hub Node'}) + for plan in data_migration_plans: + plan_doc = frappe.get_doc("Data Migration Plan", plan.name) + for m in plan_doc.get("mappings"): + frappe.delete_doc("Data Migration Mapping", m.mapping, force=True) + frappe.delete_doc("Data Migration Plan", plan.name) + + frappe.delete_doc("Module Def", "Hub Node", ignore_missing=True) + \ No newline at end of file diff --git a/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py b/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py index 587fee1f9a..a8d90499d8 100644 --- a/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py +++ b/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py @@ -7,7 +7,6 @@ from erpnext.setup.doctype.company.company import install_country_fixtures def execute(): frappe.reload_doc("accounts", "doctype", "account") - frappe.reload_doc("hub_node", "doctype", "hub_category") frappe.reload_doc("accounts", "doctype", "payment_schedule") for d in frappe.get_all('Company', filters={'country': ('in', ['Saudi Arabia', 'United Arab Emirates'])}): diff --git a/erpnext/patches/v8_1/setup_gst_india.py b/erpnext/patches/v8_1/setup_gst_india.py index a9133ae9a6..5370fa2aa5 100644 --- a/erpnext/patches/v8_1/setup_gst_india.py +++ b/erpnext/patches/v8_1/setup_gst_india.py @@ -4,7 +4,6 @@ from frappe.email import sendmail_to_system_managers def execute(): frappe.reload_doc('stock', 'doctype', 'item') frappe.reload_doc("stock", "doctype", "customs_tariff_number") - frappe.reload_doc("hub_node", "doctype", "hub_category") frappe.reload_doc("accounts", "doctype", "payment_terms_template") frappe.reload_doc("accounts", "doctype", "payment_schedule")