2020-06-19 10:03:21 +00:00
|
|
|
# Copyright (c) 2019, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
|
|
|
|
import frappe
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2021-08-27 12:30:16 +00:00
|
|
|
from erpnext.accounts.utils import check_and_delete_linked_reports
|
2020-06-19 10:03:21 +00:00
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2020-06-19 10:03:21 +00:00
|
|
|
def execute():
|
|
|
|
reports_to_delete = ["Ordered Items To Be Delivered", "Ordered Items To Be Billed"]
|
|
|
|
|
|
|
|
for report in reports_to_delete:
|
|
|
|
if frappe.db.exists("Report", report):
|
2022-01-25 05:44:08 +00:00
|
|
|
delete_links_from_desktop_icons(report)
|
2020-06-19 10:03:21 +00:00
|
|
|
delete_auto_email_reports(report)
|
2021-08-27 12:30:16 +00:00
|
|
|
check_and_delete_linked_reports(report)
|
2020-06-19 10:03:21 +00:00
|
|
|
|
|
|
|
frappe.delete_doc("Report", report)
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2020-06-19 10:03:21 +00:00
|
|
|
def delete_auto_email_reports(report):
|
|
|
|
"""Check for one or multiple Auto Email Reports and delete"""
|
|
|
|
auto_email_reports = frappe.db.get_values("Auto Email Report", {"report": report}, ["name"])
|
|
|
|
for auto_email_report in auto_email_reports:
|
|
|
|
frappe.delete_doc("Auto Email Report", auto_email_report[0])
|
2022-01-25 05:44:08 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2022-01-25 05:44:08 +00:00
|
|
|
def delete_links_from_desktop_icons(report):
|
|
|
|
"""Check for one or multiple Desktop Icons and delete"""
|
|
|
|
desktop_icons = frappe.db.get_values("Desktop Icon", {"_report": report}, ["name"])
|
|
|
|
for desktop_icon in desktop_icons:
|
|
|
|
frappe.delete_doc("Desktop Icon", desktop_icon[0])
|