diff --git a/frappe/desk/doctype/dashboard_chart/dashboard_chart.js b/frappe/desk/doctype/dashboard_chart/dashboard_chart.js index 42f1245901..99ba49bc4f 100644 --- a/frappe/desk/doctype/dashboard_chart/dashboard_chart.js +++ b/frappe/desk/doctype/dashboard_chart/dashboard_chart.js @@ -40,6 +40,7 @@ frappe.ui.form.on('Dashboard Chart', { timespan: function(frm) { const time_interval_options = { + "Select Date Range": ["Quarterly", "Monthly", "Weekly", "Daily"], "Last Year": ["Quarterly", "Monthly", "Weekly", "Daily"], "Last Quarter": ["Monthly", "Weekly", "Daily"], "Last Month": ["Weekly", "Daily"], diff --git a/frappe/desk/doctype/dashboard_chart/dashboard_chart.json b/frappe/desk/doctype/dashboard_chart/dashboard_chart.json index 2e5540536f..200e191ae1 100644 --- a/frappe/desk/doctype/dashboard_chart/dashboard_chart.json +++ b/frappe/desk/doctype/dashboard_chart/dashboard_chart.json @@ -18,6 +18,8 @@ "number_of_groups", "column_break_6", "timespan", + "from_date", + "to_date", "time_interval", "timeseries", "filters_section", @@ -80,7 +82,7 @@ "fieldname": "timespan", "fieldtype": "Select", "label": "Timespan", - "options": "Last Year\nLast Quarter\nLast Month\nLast Week" + "options": "Last Year\nLast Quarter\nLast Month\nLast Week\nSelect Date Range" }, { "depends_on": "timeseries", @@ -171,9 +173,21 @@ "fieldname": "number_of_groups", "fieldtype": "Int", "label": "Number of Groups" + }, + { + "depends_on": "eval:doc.timespan === 'Choose Time Span'", + "fieldname": "from_date", + "fieldtype": "Date", + "label": "From Date" + }, + { + "depends_on": "eval:doc.timespan === 'Choose Time Span'", + "fieldname": "to_date", + "fieldtype": "Date", + "label": "To Date" } ], - "modified": "2019-10-11 16:11:17.051669", + "modified": "2019-10-29 02:26:14.838057", "modified_by": "Administrator", "module": "Desk", "name": "Dashboard Chart", diff --git a/frappe/desk/doctype/dashboard_chart/dashboard_chart.py b/frappe/desk/doctype/dashboard_chart/dashboard_chart.py index 946a866c0d..845eaa9055 100644 --- a/frappe/desk/doctype/dashboard_chart/dashboard_chart.py +++ b/frappe/desk/doctype/dashboard_chart/dashboard_chart.py @@ -12,13 +12,15 @@ from frappe.model.document import Document @frappe.whitelist() @cache_source -def get(chart_name = None, chart = None, no_cache = None, from_date=None, to_date=None, refresh = None): +def get(chart_name = None, chart = None, no_cache = None, from_date = None, to_date = None, refresh = None): if chart_name: chart = frappe.get_doc('Dashboard Chart', chart_name) else: chart = frappe._dict(frappe.parse_json(chart)) timespan = chart.timespan + from_date = chart.from_date + to_date = chart.to_date timegrain = chart.time_interval filters = frappe.parse_json(chart.filters_json)