2020-06-19 10:03:21 +00:00
|
|
|
# Copyright (c) 2019, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
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):
|
|
|
|
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)
|
|
|
|
|
|
|
|
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])
|