From a13794495556da0d1d00d981efc2d571e1868c91 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 13:29:41 +0530 Subject: [PATCH] fix: patch to rename group_by filter in custom reports (backport #47709) (#47730) * fix: patch to rename group_by filter in custom reports (cherry picked from commit 0d19c18c0628fc7f4a2727c8e5c9d0fe0f93d66d) # Conflicts: # erpnext/patches.txt * fix: using python instead of sql query (cherry picked from commit 48eccb1f734a1e0e158e28892759bc77c6e4904e) * chore: resolve conflict --------- Co-authored-by: diptanilsaha --- erpnext/patches.txt | 1 + ...p_by_to_categorize_by_in_custom_reports.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 erpnext/patches/v15_0/rename_group_by_to_categorize_by_in_custom_reports.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index cf8ae44a8d7..fb8c625f6c7 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -404,3 +404,4 @@ erpnext.patches.v15_0.update_payment_schedule_fields_in_invoices erpnext.patches.v15_0.rename_group_by_to_categorize_by execute:frappe.db.set_single_value("Accounts Settings", "receivable_payable_fetch_method", "Buffered Cursor") erpnext.patches.v14_0.set_update_price_list_based_on +erpnext.patches.v15_0.rename_group_by_to_categorize_by_in_custom_reports diff --git a/erpnext/patches/v15_0/rename_group_by_to_categorize_by_in_custom_reports.py b/erpnext/patches/v15_0/rename_group_by_to_categorize_by_in_custom_reports.py new file mode 100644 index 00000000000..bc671a4a6ac --- /dev/null +++ b/erpnext/patches/v15_0/rename_group_by_to_categorize_by_in_custom_reports.py @@ -0,0 +1,24 @@ +import json + +import frappe + + +def execute(): + custom_reports = frappe.get_all( + "Report", + filters={ + "report_type": "Custom Report", + "reference_report": ["in", ["General Ledger", "Supplier Quotation Comparison"]], + }, + fields=["name", "json"], + ) + + for report in custom_reports: + report_json = json.loads(report.json) + + if "filters" in report_json and "group_by" in report_json["filters"]: + report_json["filters"]["categorize_by"] = ( + report_json["filters"].pop("group_by").replace("Group", "Categorize") + ) + + frappe.db.set_value("Report", report.name, "json", json.dumps(report_json))