diff --git a/frappe/email/doctype/email_group/email_group.py b/frappe/email/doctype/email_group/email_group.py old mode 100644 new mode 100755 index c96ad632c2..20daedb8d3 --- a/frappe/email/doctype/email_group/email_group.py +++ b/frappe/email/doctype/email_group/email_group.py @@ -4,7 +4,10 @@ from __future__ import unicode_literals import frappe +from frappe import _ +from frappe.utils import validate_email_add from frappe.model.document import Document +from email.utils import parseaddr class EmailGroup(Document): def onload(self): @@ -90,10 +93,10 @@ def add_subscribers(name, email_list): def restrict_email_group(doc, method): from frappe.limits import get_limits - email_group_limit = get_limits().get('newsletter_recipients') + email_group_limit = get_limits().get('email_group_limit') if not email_group_limit: return - nl = frappe.get_doc("Email Group", doc.email_group) - if nl.get_total_subscribers() >= email_group_limit: + email_group = frappe.get_doc("Email Group", doc.email_group) + if email_group.get_total_subscribers() >= email_group_limit: frappe.throw(_("Please Upgrade to add more than {0} subscribers").format(email_group_limit)) diff --git a/frappe/hooks.py b/frappe/hooks.py index cc76442c14..717af665c2 100755 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -99,7 +99,6 @@ doc_events = { "after_insert": "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts", "validate": [ "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts", - "frappe.email.doctype.email_group.email_group.restrict_email_group" ], "on_update": [ "frappe.desk.notifications.clear_doctype_notifications", @@ -115,7 +114,11 @@ doc_events = { "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts" ], "on_trash": "frappe.desk.notifications.clear_doctype_notifications" - } + }, + "Email Group Member": { + "validate": "frappe.email.doctype.email_group.email_group.restrict_email_group" + }, + } scheduler_events = {