SQL Query Report

487 views
Skip to first unread message

Akshay Mehta

unread,
Aug 15, 2014, 4:22:03 AM8/15/14
to erpnext-u...@googlegroups.com
Hi,

Is there a way we can add and work with Parameters (?) in the SQL Query Report? If yes can anybody quote an example.

regards
Akshay Mehta

Rushabh Mehta

unread,
Aug 15, 2014, 12:40:17 PM8/15/14
to erpnext-u...@googlegroups.com
On 15-Aug-2014, at 1:52 pm, Akshay Mehta <mehta....@gmail.com> wrote:

Hi,

Is there a way we can add and work with Parameters (?) in the SQL Query Report? If yes can anybody quote an example.

Check how you can set filters:



regards
Akshay Mehta

--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/CAMgq%3DkeQPCjUMysn8EgtTNtC%3DC_jLpZUPpjPtHt7j3UwDLfGDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Akshay Mehta

unread,
Aug 16, 2014, 3:20:41 AM8/16/14
to erpnext-u...@googlegroups.com

Akshay Mehta

unread,
Sep 1, 2014, 4:01:32 AM9/1/14
to erpnext-u...@googlegroups.com
Hi,

I was successful in using the following TYPE of Custom report, but today it is giving an error :

Query Report :

select * from `tabItem` where name like %(name)s

Javascript:

frappe.query_reports['Test Query Parameter'] = {

    "filters": [

       {

       "fieldname":"name",

       "label":__("Item Name"),

       "fieldtype": "Data",

       }

    ]

}


Error :

Traceback (innermost last):

  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 49, in application

    response = frappe.handler.handle()

  File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle

    execute_cmd(cmd)

  File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd

    ret = frappe.call(method, **frappe.form_dict)

  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 529, in call

    return fn(*args, **newargs)

  File "/home/erpnext/frappe-bench/apps/frappe/frappe/widgets/query_report.py", line 81, in run

    result = [list(t) for t in frappe.db.sql(report.query, filters)]

  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database.py", line 108, in sql

    self._cursor.execute(query, values)

  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 185, in execute

    for key, item in args.iteritems())

 KeyError: 'name'


Any Idea?


regards

Akshay

Anand Doshi

unread,
Sep 1, 2014, 6:25:21 AM9/1/14
to ERPNext User's Forum
also set "reqd": 1 for that filter and try.

-Anand.


Akshay Mehta

unread,
Sep 1, 2014, 6:41:51 AM9/1/14
to erpnext-u...@googlegroups.com
does not work ... same error

akshay


Anand Doshi

unread,
Sep 1, 2014, 6:49:39 AM9/1/14
to ERPNext User's Forum
Check if you are passing some value in "Item Code".

Also, confirm if the report's name is "Test Query Report", since you are using frappe.query_reports['Test Query Parameter']


Akshay Mehta

unread,
Sep 2, 2014, 3:49:02 AM9/2/14
to erpnext-u...@googlegroups.com
Yes I think I was not putting any value in the field ....

Is it possible to set "default":"%%"? I tried this but did not work.

Akshay



Anand Doshi

unread,
Sep 2, 2014, 4:49:33 AM9/2/14
to ERPNext User's Forum
Hi Akshay,

Should work. After saving the report, go to Help > Clear Cache and try after that

-Anand.


Reply all
Reply to author
Forward
0 new messages