From 6daa6e422e2f8ee7b06203c656a3f550d4a7c335 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Wed, 28 Jun 2017 13:24:44 +0530 Subject: [PATCH] [fix] delete/update desktop icon for deprecated report --- .../patches/v8_1/delete_deprecated_reports.py | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v8_1/delete_deprecated_reports.py b/erpnext/patches/v8_1/delete_deprecated_reports.py index 2cb84a9a5fa..7e861319bf8 100644 --- a/erpnext/patches/v8_1/delete_deprecated_reports.py +++ b/erpnext/patches/v8_1/delete_deprecated_reports.py @@ -7,9 +7,25 @@ import frappe def execute(): """ delete deprecated reports """ - reports = ["Monthly Salary Register", "Customer Addresses And Contacts", - "Supplier Addresses And Contacts"] + reports = [ + "Monthly Salary Register", "Customer Addresses And Contacts", + "Supplier Addresses And Contacts" + ] for report in reports: if frappe.db.exists("Report", report): - frappe.delete_doc("Report", report, ignore_permissions=True) \ No newline at end of file + check_and_update_desktop_icon_for_report(report) + frappe.delete_doc("Report", report, ignore_permissions=True) + +def check_and_update_desktop_icon_for_report(report): + """ delete desktop icon for deprecated desktop icon and update the _report for Addresses And Contacts""" + + if report == "Monthly Salary Register": + frappe.delete_doc("Desktop Icon", report) + + elif report in ["Customer Addresses And Contacts", "Supplier Addresses And Contacts"]: + name = frappe.db.get_value("Desktop Icon", {"_report": report}) + if name: + frappe.db.set_value("Desktop Icon", name, "_report", "Addresses And Contacts") + + frappe.db.commit()