2017-06-22 10:48:12 +00:00
|
|
|
# Copyright (c) 2017, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
|
|
|
""" delete deprecated reports """
|
|
|
|
|
2017-06-28 07:54:44 +00:00
|
|
|
reports = [
|
|
|
|
"Monthly Salary Register", "Customer Addresses And Contacts",
|
|
|
|
"Supplier Addresses And Contacts"
|
|
|
|
]
|
2017-06-22 10:48:12 +00:00
|
|
|
|
|
|
|
for report in reports:
|
|
|
|
if frappe.db.exists("Report", report):
|
2017-06-28 07:54:44 +00:00
|
|
|
check_and_update_desktop_icon_for_report(report)
|
2017-06-28 12:31:58 +00:00
|
|
|
check_and_update_auto_email_report(report)
|
|
|
|
frappe.db.commit()
|
|
|
|
|
2017-06-28 07:54:44 +00:00
|
|
|
frappe.delete_doc("Report", report, ignore_permissions=True)
|
|
|
|
|
|
|
|
def check_and_update_desktop_icon_for_report(report):
|
2017-06-28 12:31:58 +00:00
|
|
|
""" delete or update desktop icon"""
|
|
|
|
desktop_icons = frappe.db.sql_list("""select name from `tabDesktop Icon`
|
|
|
|
where _report='{0}'""".format(report))
|
|
|
|
|
|
|
|
if not desktop_icons:
|
|
|
|
return
|
2017-06-28 07:54:44 +00:00
|
|
|
|
|
|
|
if report == "Monthly Salary Register":
|
2017-06-28 12:31:58 +00:00
|
|
|
for icon in desktop_icons:
|
|
|
|
frappe.delete_doc("Desktop Icon", icon)
|
2017-06-28 07:54:44 +00:00
|
|
|
|
|
|
|
elif report in ["Customer Addresses And Contacts", "Supplier Addresses And Contacts"]:
|
2017-06-28 12:31:58 +00:00
|
|
|
frappe.db.sql("""update `tabDesktop Icon` set _report='{value}'
|
|
|
|
where name in ({docnames})""".format(
|
2017-06-29 16:17:14 +00:00
|
|
|
value="Addresses And Contacts",
|
2017-06-28 12:31:58 +00:00
|
|
|
docnames=",".join(["'%s'"%icon for icon in desktop_icons])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
def check_and_update_auto_email_report(report):
|
|
|
|
""" delete or update auto email report for deprecated report """
|
|
|
|
|
|
|
|
auto_email_report = frappe.db.get_value("Auto Email Report", {"report": report})
|
|
|
|
if not auto_email_report:
|
|
|
|
return
|
2017-06-28 07:54:44 +00:00
|
|
|
|
2017-06-28 12:31:58 +00:00
|
|
|
if report == "Monthly Salary Register":
|
|
|
|
frappe.delete_doc("Auto Email Report", auto_email_report)
|
|
|
|
|
|
|
|
elif report in ["Customer Addresses And Contacts", "Supplier Addresses And Contacts"]:
|
|
|
|
frapppe.db.set_value("Auto Email Report", auto_email_report, "report", report)
|