Try ERPNext Buy Support Partners Foundation

How to add FROM Date and TO Date in ERPNext Query Report

@ValS

Noted with thanks.

@marination

Thank you for the assistance.

Here is the .py:
How to add FROM Date and TO Date in ERPNext Query Report

And the .js is identical to what is mentioned here:

Thanks in advance.

If this still is the issue, there could be a missing comma in your .js file , which is why i asked if i could see your .js. I understand that it is similar to the one above, but clearly there is a minor error. It should work fine otherwise. Also what do you see on your screen ? Does it go blank? Its hard to debug without knowing what is going on here

@marination

Here is the .js

frappe.query_reports["sales report"] = {
	"filters": [
	{
		"fieldname":"from_date",
		"label": __("From Date"),
		"fieldtype": "Date",
		"width": "80",
		"reqd": 1,
		"default": frappe.datetime.month_start()
	},
	{
		"fieldname":"to_date",
		"label": __("To Date"),
		"fieldtype": "Date",
		"reqd": 1,
		"width": "80",
		"default": frappe.datetime.month_end()
	}

	]
}

Thanks in advance

@marination

:wave:

@clarkej

This issue is still unresolved.

The marked solution was in response to a request for more data

1 Like

@marination

Just bumping this up in case you missed it.

frappe.query_reports["sales report"] = {
	"filters": [
	{
		"fieldname":"from_date",
		"label": __("From Date"),
		"fieldtype": "Date",
		"width": "80",
		"reqd": 1,
		"default": frappe.datetime.month_start()
	},
	{
		"fieldname":"to_date",
		"label": __("To Date"),
		"fieldtype": "Date",
		"reqd": 1,
		"width": "80",
		"default": frappe.datetime.month_end()
	}

	]
}

Maybe terminate that expression with ‘;’

An online Javascript validator complains that is missing!

For example

@clarkej

Thank you very much for following up.
I am so ashamed of the mistake I had been making that wasted everyone’s time.

I only realized yesterday that the report’s name value is case sensitive!

Instead of
frappe.query_reports["sales report"]

is should have been

frappe.query_reports["Sales Report"]

After making this small change, everything worked as advertised!

On the contrary I disagree @Eli - mistakes are human and inevitable and learning is never wasted time - you also have informed me and many more too.

Yet another discovery and bug prospect for me just now as a result:

A DocType name must be capitalised - ERPNext forces that rule by simply capitalising name violations when it saves and validates a new DocType.

However for a new Query Report, ERPNext does not apply that same rule in that case too?

And that can mean confusion as you have found.

Attached is my test case Query Report named ‘dummy doctype query report’ :slight_smile: