Query Report Empty Filter

Im trying to create a report which by default has no value, and will only affect the report if it has some Value.

But I get the following error:

Traceback (innermost last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 57, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 806, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/query_report.py", line 82, in run
    result = [list(t) for t in frappe.db.sql(report.query, filters)]
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 136, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/cursors.py", line 185, in execute
    for key, item in args.iteritems())
 KeyError: 'sales_exec'

SQL Code:

WHERE (tabSales Person.sales_person_name = %(sales_exec)s)

JS Code:

{
    			"fieldname":"sales_exec",
    			"label": __("Sales Executive"),
    			"fieldtype": "Link",
    			"options": "Sales Person"
},

Can anybody help me out with showing the entire data if no filter is selected?

Thanks!

@Tanuj, for that case, I think that a script report will be a better option to you, due you can build the SQL based in the filters that do you receive from the UI.

@max_morais_dmm
Alright!

Thanks for your help Max

@Tanuj, you are wellcome!

@max_morais_dmm

Hi Max,

I’m trying to convert the Query Report to a Script Report, but unable to do so successfully. Could you point me to an existing report which I can use as an example?

Thanks so much!

@Tanuj https://github.com/frappe/erpnext/blob/develop/erpnext/accounts/report/sales_register/sales_register.py#L84

This topic was automatically closed after 2 days. New replies are no longer allowed.