diff --git a/frappe/core/doctype/prepared_report/prepared_report.js b/frappe/core/doctype/prepared_report/prepared_report.js index 002e069874..6a7cf2728c 100644 --- a/frappe/core/doctype/prepared_report/prepared_report.js +++ b/frappe/core/doctype/prepared_report/prepared_report.js @@ -15,7 +15,7 @@ frappe.ui.form.on('Prepared Report', { `); - const filters = JSON.parse(JSON.parse(frm.doc.filters)); + const filters = JSON.parse(frm.doc.filters); Object.keys(filters).forEach(key => { const filter_row = $(` diff --git a/frappe/core/doctype/prepared_report/prepared_report.py b/frappe/core/doctype/prepared_report/prepared_report.py index df4f577766..887a766372 100644 --- a/frappe/core/doctype/prepared_report/prepared_report.py +++ b/frappe/core/doctype/prepared_report/prepared_report.py @@ -35,7 +35,7 @@ class PreparedReport(Document): def run_background(instance): report = frappe.get_doc("Report", instance.ref_report_doctype) - result = generate_report_result(report, filters=json.loads(instance.filters), user=instance.owner) + result = generate_report_result(report, filters=instance.filters, user=instance.owner) create_json_gz_file(result['result'], 'Prepared Report', instance.name) instance.status = "Completed" diff --git a/frappe/desk/query_report.py b/frappe/desk/query_report.py index 3c89343af1..2e5d077cd1 100644 --- a/frappe/desk/query_report.py +++ b/frappe/desk/query_report.py @@ -100,7 +100,9 @@ def background_enqueue_run(report_name, filters=None, user=None): frappe.get_doc({ "doctype": "Prepared Report", "report_name": report_name, - "filters": json.dumps(filters), + # This looks like an insanity but, without this it'd be very hard to find Prepared Reports matvhing 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)), "ref_report_doctype": report_name, "report_type": report.report_type, "query": report.query,