f469ec87d9
* chore: patch fixes (cherry picked from commit 8b5b146f6d2720587a16f78a8d47840be8dca2b7) # Conflicts: # erpnext/patches/v13_0/make_homepage_products_website_items.py * fix: remove desktop icons while deleting sales reports (cherry picked from commit 5f72026cb932d01fc827c382747e996a94b441fd) * refactor: dont ignore dangerous exceptions in patches (cherry picked from commit 0aa1ea8aeb7757592616bd491de98c69fef08854) * fix: make patch kinda idempotent with previous query rerunning would've caused all values to become 0. * chore: conflicts * fix: check type before patching Co-authored-by: Saurabh <saurabh6790@gmail.com> Co-authored-by: Ankush Menat <ankush@frappe.io>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
# Copyright (c) 2019, Frappe and Contributors
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
import frappe
|
|
|
|
from erpnext.accounts.utils import check_and_delete_linked_reports
|
|
|
|
|
|
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_links_from_desktop_icons(report)
|
|
delete_auto_email_reports(report)
|
|
check_and_delete_linked_reports(report)
|
|
|
|
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])
|
|
|
|
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]) |