Merge pull request #2556 from saurabh6790/auto_email_report_fix

[fix] validate filters before sending a email
This commit is contained in:
Nabin Hait 2017-01-09 16:03:22 +05:30 committed by GitHub
commit be5d73c5eb
3 changed files with 32 additions and 19 deletions

View file

@ -63,6 +63,7 @@ frappe.ui.form.on('Auto Email Report', {
var filters = JSON.parse(frm.doc.filters || '{}');
var report_filters = frappe.query_reports[frm.doc.report].filters;
frm.set_value('filter_meta', JSON.stringify(report_filters));
report_filters_list = []
$.each(report_filters, function(key, val){

View file

@ -24,7 +24,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Report",
"length": 0,
"no_copy": 0,
@ -54,7 +53,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Based on Permissions For User",
"length": 0,
"no_copy": 0,
@ -84,7 +82,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Enabled",
"length": 0,
"no_copy": 0,
@ -113,7 +110,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Send only if there is any data",
"length": 0,
"no_copy": 0,
@ -141,7 +137,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -168,7 +163,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Report Type",
"length": 0,
"no_copy": 0,
@ -199,7 +193,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "No of Rows (Max 500)",
"length": 0,
"no_copy": 0,
@ -228,7 +221,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Report Filters",
"length": 0,
"no_copy": 0,
@ -256,7 +248,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Filters Display",
"length": 0,
"no_copy": 0,
@ -284,7 +275,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Filters",
"length": 0,
"no_copy": 0,
@ -300,6 +290,33 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "filter_meta",
"fieldtype": "Text",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Filter Meta",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -312,7 +329,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Settings",
"length": 0,
"no_copy": 0,
@ -340,7 +356,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email To",
"length": 0,
"no_copy": 0,
@ -370,7 +385,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Day of Week",
"length": 0,
"no_copy": 0,
@ -399,7 +413,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -426,7 +439,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Frequency",
"length": 0,
"no_copy": 0,
@ -455,7 +467,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Format",
"length": 0,
"no_copy": 0,
@ -484,7 +495,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Message",
"length": 0,
"no_copy": 0,
@ -512,7 +522,6 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Message",
"length": 0,
"no_copy": 0,
@ -539,7 +548,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-07 05:50:31.903959",
"modified": "2017-01-07 14:27:19.605466",
"modified_by": "Administrator",
"module": "Email",
"name": "Auto Email Report",

View file

@ -69,6 +69,9 @@ class AutoEmailReport(Document):
return "{0}.{1}".format(self.report.replace(" ", "-").replace("/", "-"), self.format.lower())
def send(self):
if self.filter_meta and not self.filters:
frappe.throw(_("Please set filters value in Report Filter table."))
data = self.get_report_content()
if not data:
return