ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

[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/", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 53, in execute_cmd
    return, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", 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) {'Download to CSV (CUSTOMISE)'), function () {
				method: "",
				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); = '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 ?