[Custom] Error make filter in report script

help me to fixed error my report

i have code :

def get_conditions(filters):
	conditions = ""
	if filters.get("from_date"):
		conditions += " and posting_date>=%(from_date)s"
	if filters.get("to_date"):
		conditions += " and posting_date<=%(to_date)s"
	return conditions

def download1(filters):

	conditions = get_conditions(filters)

                                         "JUMLAH_DPP", "JUMLAH_PPN", "JUMLAH_PPNBM", "ID_KETERANGAN_TAMBAHAN", "FG_UANG_MUKA", "UANG_MUKA_DPP", "UANG_MUKA_PPN", "UANG_MUKA_PPNBM", 'REFERENSI']))) + '\"' + "\n"
	content += '\"' + '"|"'.join(map(str, (["LT", "NPWP", "NAMA", "JALAN", "BLOK", "NOMOR", "RT", "RW",
                                         "KECAMATAN", "KELURAHAN", "KABUPATEN", "PROPINSI", "KODE_POS", "NOMOR_TELEPON"]))) + '\"' + "\n"
	content += '\"' + '"|"'.join(map(str, (["OF", "KODE_OBJEK", "NAMA", "HARGA_SATUAN", "JUMLAH_BARANG",
                                         "HARGA_TOTAL", "DISKON", "DPP", "PPN", "TARIF_PPNBM", "PPNBM"]))) + '\"' + "\n" 

and i have error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
TypeError: download1() takes exactly 1 argument (0 given)

and my js script :

// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* eslint-disable */

frappe.query_reports["Sales invoice script"] = {
	"filters": [
			"fieldname": "from_date",
			"label": __("From Date"),
			"fieldtype": "Date",
			"default": frappe.defaults.get_user_default("year_start_date"),
			"width": "80"

			"fieldname": "to_date",
			"label": __("To Date"),
			"fieldtype": "Date",
			"default": frappe.datetime.get_today()

	onload: function (report) {
		report.page.add_inner_button(__('Download to CSV (CUSTOMISE)'), function () {
			return frappe.call({
				method: "erpnext.accounts.report.sales_invoice_script.sales_invoice_script.download1",
				args: {},
				callback: function (r) {
					// download("TAX Develop.csv", r.message.content);
					// frappe.msgprint("CSV Berhasil Di Download");
			function download(filename, content) {
				var element = document.createElement('a');
				element.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(content));
				element.setAttribute('download', filename);
				element.style.display = 'none';

The traceback is very clear. You need to pass the right arguments

@rmehta thanks for reply,
how i pass the right arguments?

how to get value args js to python script?

this python code :

def download(filters):
	conditions = ""
	if filters.get("from_date"):
		conditions += "and posting_date>=%(from_date)s"
	if filters.get("to_date"):
		conditions += "and posting_date<=%(to_date)s"

if i use this python code, its didnt work, and eror attribut get

You are declaring on Python that download needs only one argument i.e. filters.

Whereas from the JS you are sending two arguments, from_date and to_date. That is the problem.

hai @root13F thanks for reply,

if i make js:

how i call value fieldname:from_date and to_date in filter report to args in button js?

or how to get value in python when i have from date and to_date in js :

and python code :

def download(data):


return date

You need to change definition of download function.

From this

def download(data):

to this

def download(from_date, to_date):

thanks all this problem solved…

how did you solve it ?

can you help me i am trying to pass the date filter to my paython function but when i am passing according to your code it showing
NameError: name ‘posting_date’ is not defined

this error i taking posting_date as filter arg as you take from_date and to_date .
what is the issue…i am trying since long…


return frappe.call({
	        type : "POST",
			args: {
		        posting_date : "2021-08-01"


def get_test1_api(posting_date):

can you help?

Hello @Rehan_Ansari

Please have a look at [Tutorial] Script Report / Chart where I define numerous date filters in JS and then access their values in Python.

didn’t find any solutions from this