From 5f72026cb932d01fc827c382747e996a94b441fd Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 6 Jan 2022 15:45:52 +0530 Subject: [PATCH] fix: remove desktop icons while deleting sales reports --- erpnext/patches/v12_0/update_is_cancelled_field.py | 9 ++++----- erpnext/patches/v13_0/delete_old_sales_reports.py | 7 +++++++ .../setup_fields_for_80g_certificate_and_donation.py | 3 +++ .../v13_0/update_actual_start_and_end_date_in_wo.py | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/erpnext/patches/v12_0/update_is_cancelled_field.py b/erpnext/patches/v12_0/update_is_cancelled_field.py index 4ef2d05d7aa..989ea380e9a 100644 --- a/erpnext/patches/v12_0/update_is_cancelled_field.py +++ b/erpnext/patches/v12_0/update_is_cancelled_field.py @@ -5,15 +5,14 @@ import frappe def execute(): #handle type casting for is_cancelled field - for doc_mapper in (('stock','Stock Ledger Entry'), - ('stock','Serial No'), - ('accounts','GL Entry')): + for doc_mapper in (('stock','Stock Ledger Entry'), + ('stock','Serial No'), + ('accounts','GL Entry')): try: module = doc_mapper[0] doctype = doc_mapper[1] - frappe.db.sql('''UPDATE `tab{doctype}` SET is_cancelled = - CASE + frappe.db.sql('''UPDATE `tab{doctype}` SET is_cancelled = CASE WHEN is_cancelled = 'No' THEN 0 WHEN is_cancelled = 'Yes' THEN 1 ELSE 0 diff --git a/erpnext/patches/v13_0/delete_old_sales_reports.py b/erpnext/patches/v13_0/delete_old_sales_reports.py index c597fe86457..e6eba0a6085 100644 --- a/erpnext/patches/v13_0/delete_old_sales_reports.py +++ b/erpnext/patches/v13_0/delete_old_sales_reports.py @@ -12,6 +12,7 @@ def execute(): 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) @@ -22,3 +23,9 @@ def delete_auto_email_reports(report): 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]) \ No newline at end of file diff --git a/erpnext/patches/v13_0/setup_fields_for_80g_certificate_and_donation.py b/erpnext/patches/v13_0/setup_fields_for_80g_certificate_and_donation.py index 7a2a2539670..2d35ea34587 100644 --- a/erpnext/patches/v13_0/setup_fields_for_80g_certificate_and_donation.py +++ b/erpnext/patches/v13_0/setup_fields_for_80g_certificate_and_donation.py @@ -5,6 +5,9 @@ from erpnext.regional.india.setup import make_custom_fields def execute(): if frappe.get_all('Company', filters = {'country': 'India'}): + frappe.reload_doc('accounts', 'doctype', 'POS Invoice') + frappe.reload_doc('accounts', 'doctype', 'POS Invoice Item') + make_custom_fields() if not frappe.db.exists('Party Type', 'Donor'): diff --git a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py index 10ecd093069..9993063e485 100644 --- a/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py +++ b/erpnext/patches/v13_0/update_actual_start_and_end_date_in_wo.py @@ -38,4 +38,4 @@ def execute(): jc.production_item = wo.production_item, jc.item_name = wo.item_name WHERE jc.work_order = wo.name and IFNULL(jc.production_item, "") = "" - """) + """) \ No newline at end of file