diff --git a/frappe/__init__.py b/frappe/__init__.py index fc72640a6f88..96ecd65558d0 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -42,7 +42,7 @@ ) from .utils.lazy_loader import lazy_import -__version__ = "14.19.0" +__version__ = "14.19.1" __title__ = "Frappe Framework" controllers = {} diff --git a/frappe/core/doctype/prepared_report/prepared_report.py b/frappe/core/doctype/prepared_report/prepared_report.py index 0b8e25229d5c..51f6cd63a1f1 100644 --- a/frappe/core/doctype/prepared_report/prepared_report.py +++ b/frappe/core/doctype/prepared_report/prepared_report.py @@ -68,7 +68,7 @@ def get_reports_in_queued_state(report_name, filters): "Prepared Report", filters={ "report_name": report_name, - "filters": json.dumps(json.loads(filters)), + "filters": process_filters_for_prepared_report(filters), "status": "Queued", }, ) @@ -102,6 +102,17 @@ def delete_prepared_reports(reports): ) +def process_filters_for_prepared_report(filters): + if isinstance(filters, str): + filters = json.loads(filters) + + # This looks like an insanity but, without this it'd be very hard to find Prepared Reports matching given condition + # We're ensuring that spacing is consistent. e.g. JS seems to put no spaces after ":", Python on the other hand does. + # We are also ensuring that order of keys is same so generated JSON string will be identical too. + # PS: frappe.as_json sorts keys + return frappe.as_json(filters, indent=None, separators=(",", ":")) + + def create_json_gz_file(data, dt, dn): # Storing data in CSV file causes information loss # Reports like P&L Statement were completely unsuable because of this diff --git a/frappe/desk/query_report.py b/frappe/desk/query_report.py index f885c97e6d2f..81b113dcd703 100644 --- a/frappe/desk/query_report.py +++ b/frappe/desk/query_report.py @@ -147,6 +147,10 @@ def normalize_result(result, columns): @frappe.whitelist() def background_enqueue_run(report_name, filters=None, user=None): """run reports in background""" + from frappe.core.doctype.prepared_report.prepared_report import ( + process_filters_for_prepared_report, + ) + if not user: user = frappe.session.user report = get_report_doc(report_name) @@ -154,9 +158,7 @@ def background_enqueue_run(report_name, filters=None, user=None): { "doctype": "Prepared Report", "report_name": report_name, - # This looks like an insanity but, without this it'd be very hard to find Prepared Reports matching given condition - # We're ensuring that spacing is consistent. e.g. JS seems to put no spaces after ":", Python on the other hand does. - "filters": json.dumps(json.loads(filters)), + "filters": process_filters_for_prepared_report(filters), "ref_report_doctype": report_name, "report_type": report.report_type, "query": report.query, @@ -271,6 +273,10 @@ def add_custom_column_data(custom_columns, result): def get_prepared_report_result(report, filters, dn="", user=None): + from frappe.core.doctype.prepared_report.prepared_report import ( + process_filters_for_prepared_report, + ) + latest_report_data = {} doc = None if dn: @@ -282,7 +288,7 @@ def get_prepared_report_result(report, filters, dn="", user=None): "Prepared Report", filters={ "status": "Completed", - "filters": json.dumps(filters), + "filters": process_filters_for_prepared_report(filters), "owner": user, "report_name": report.get("custom_report") or report.get("report_name"), },