Merge pull request #5480 from vjFaLk/restrict-newsletter-list
Added code to Restrict Newsletter List Recipients
This commit is contained in:
commit
560ee7bb12
@ -89,3 +89,14 @@ def add_subscribers(name, email_list):
|
|||||||
frappe.msgprint(_("{0} subscribers added").format(count))
|
frappe.msgprint(_("{0} subscribers added").format(count))
|
||||||
|
|
||||||
return frappe.get_doc("Newsletter List", name).update_total_subscribers()
|
return frappe.get_doc("Newsletter List", name).update_total_subscribers()
|
||||||
|
|
||||||
|
def restrict_newsletter_list(doc, method):
|
||||||
|
from frappe.limits import get_limits
|
||||||
|
|
||||||
|
newsletter_list_limit = get_limits().get('newsletter_recipients')
|
||||||
|
if not newsletter_list_limit:
|
||||||
|
return
|
||||||
|
|
||||||
|
nl = frappe.get_doc("Newsletter List", doc.newsletter_list)
|
||||||
|
if nl.get_total_subscribers() >= newsletter_list_limit:
|
||||||
|
frappe.throw(_("Please Upgrade to add more than {0} subscribers").format(newsletter_list_limit))
|
@ -136,6 +136,10 @@ doc_events = {
|
|||||||
"validate": "erpnext.shopping_cart.cart.set_customer_in_address"
|
"validate": "erpnext.shopping_cart.cart.set_customer_in_address"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"Newsletter List Subscriber": {
|
||||||
|
"validate": "erpnext.crm.doctype.newsletter_list.newsletter_list.restrict_newsletter_list"
|
||||||
|
},
|
||||||
|
|
||||||
# bubble transaction notification on master
|
# bubble transaction notification on master
|
||||||
('Opportunity', 'Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice',
|
('Opportunity', 'Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice',
|
||||||
'Supplier Quotation', 'Purchase Order', 'Purchase Receipt',
|
'Supplier Quotation', 'Purchase Order', 'Purchase Receipt',
|
||||||
|
Loading…
Reference in New Issue
Block a user