From b3ebe203acba81bdd779b350690a4a368424ad6c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 26 Jan 2016 11:28:17 +0530 Subject: [PATCH] [fix] Email Alert: don't allow for child table --- frappe/email/doctype/email_alert/email_alert.js | 9 +++++++++ frappe/email/doctype/email_alert/email_alert.py | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frappe/email/doctype/email_alert/email_alert.js b/frappe/email/doctype/email_alert/email_alert.js index 2c46cc90e2..807720bb9b 100644 --- a/frappe/email/doctype/email_alert/email_alert.js +++ b/frappe/email/doctype/email_alert/email_alert.js @@ -33,6 +33,15 @@ frappe.email_alert = { } frappe.ui.form.on("Email Alert", { + onload: function(frm) { + frm.set_query("document_type", function() { + return { + "filters": { + "istable": 0 + } + } + }) + }, refresh: function(frm) { frappe.email_alert.setup_fieldname_select(frm); }, diff --git a/frappe/email/doctype/email_alert/email_alert.py b/frappe/email/doctype/email_alert/email_alert.py index 5da08920c8..8dd91de8f6 100644 --- a/frappe/email/doctype/email_alert/email_alert.py +++ b/frappe/email/doctype/email_alert/email_alert.py @@ -17,7 +17,10 @@ class EmailAlert(Document): frappe.throw(_("Please specify which value field must be checked")) forbidden_document_types = ("Bulk Email",) - if self.document_type in forbidden_document_types: + if (self.document_type in forbidden_document_types + or frappe.get_meta(self.document_type).istable): + # currently email alerts don't work on child tables as events are not fired for each record of child table + frappe.throw(_("Cannot set Email Alert on Document Type {0}").format(self.document_type)) def trigger_daily_alerts():