[fix] Email Alert: don't allow for child table

This commit is contained in:
Anand Doshi 2016-01-26 11:28:17 +05:30
parent 12ce3e0164
commit b3ebe203ac
2 changed files with 13 additions and 1 deletions

View file

@ -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);
},

View file

@ -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():