Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Key error when query report selected from module page

Hi All,
I am new to ERPNext and working with query reports. I want to add a filter in query report which I have named as “Debtor report” and was able to create a filter for to_date using a custom script for report. We wont be able to change any files from the folder as the Production site is on frappe cloud and even if we modify any files we wont be able to deploy those changes. Following is the custom script written from the UI for the “Debtor report”:
frappe.query_reports[“Debtor Report”] = {
“filters”: [
{
fieldname:“to_date”,
label: __(“Date”),
fieldtype: “Date”,
default:frappe.datetime.get_today(),
“reqd”:1
}
]
}

And have added the following in the query:
ON s.transaction_date <= %(to_date)s

This works fine when I open the report from Report list.

But when I try to open the report from selling module page, it shows me a key error for to_date. Please find the below image for reference. Could anyone please guide me if I am missing anything or something I can do to solve this.

Thanks.

Did you manage to resolve this?

If you are using a custom app,

  • then create the report under that app, you will have a folder for that report inside the custom-app.
  • Inside that folder you can have a report_name.js file and write your filter code in that file.
    Now access the query report from module, you wont find the key error.

Hello Everybody.
I’ve found two ways to resolve this problem.
The first and recommended is create script report.
But, if you don’t like do that, first go to location where frappe is installed and locate the directory:
frappe-bench\apps\frappe\frappe\public\js\frappe\views\reports
and edit file “query_report.js”
Go to line 865 under function “get_filter_values(raise)” and replace the line
.filter(f => (f.get_value()))
by
.filter(f => (f.get_value() == undefined || f.get_value() == ‘’ ? “not_defined”:f.get_value()))

Save and then run command:
“bench build”

Now the query report accept empty params