brotherton-erpnext/erpnext/patches/v10_0/delete_hub_documents.py
Chillar Anand 915b34391c
chore: Clean up imports ()
* chore: Added isort to pre-commit config

* chore: Sort imports with isort

* chore: Clean up imports with pycln

* chore: Sort imports with isort

* chore: Fix import issues

* chore: Clean up sider issues

* chore: Remove import errors from flake8 ignore list

* chore: Clean up lint issues
2021-09-02 16:44:59 +05:30

20 lines
793 B
Python

from __future__ import unicode_literals
import frappe
def execute():
for dt, dn in (("Page", "Hub"), ("DocType", "Hub Settings"), ("DocType", "Hub Category")):
frappe.delete_doc(dt, dn, ignore_missing=True)
if frappe.db.exists("DocType", "Data Migration Plan"):
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)
docs = frappe.get_all("Data Migration Run", filters={"data_migration_plan": plan.name})
for doc in docs:
frappe.delete_doc("Data Migration Run", doc.name)
frappe.delete_doc("Data Migration Plan", plan.name)