fix: New Dashboard Chart throws TypeError: format requires a mapping

closes #21250
This commit is contained in:
Vimal Patel 2023-06-07 12:25:52 +01:00
parent a21412e12a
commit 70944cabb3

View file

@ -165,7 +165,8 @@ def get_script(report_name):
script += f"\n\n//# sourceURL={scrub(report.name)}__custom"
if not script:
script = "frappe.query_reports['%s']={}" % report_name
filters = json.dumps([prepare_filter(filter) for filter in report.filters])
script = "frappe.query_reports['%s']={ 'filters': %s}" % (report_name, filters)
return {
"script": render_include(script),
@ -174,6 +175,18 @@ def get_script(report_name):
}
def prepare_filter(filter):
filter = {
"fieldname": filter.fieldname,
"label": filter.label,
"fieldtype": filter.fieldtype,
"width": "80",
"options": filter.options,
"reqd": 1
}
return filter
@frappe.whitelist()
@frappe.read_only()
def run(