brotherton-erpnext/erpnext/patches/v5_0/newsletter.py

38 lines
1.2 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
2015-03-20 04:59:30 +00:00
import frappe.permissions
def execute():
2015-03-27 05:19:41 +00:00
frappe.reload_doc("core", "doctype", "block_module")
frappe.reload_doctype("User")
frappe.reload_doctype("Lead")
frappe.reload_doctype("Contact")
frappe.reload_doc('crm', 'doctype', 'newsletter_list')
frappe.reload_doc('crm', 'doctype', 'newsletter_list_subscriber')
frappe.reload_doc('crm', 'doctype', 'newsletter')
2015-03-20 04:59:30 +00:00
frappe.permissions.reset_perms("Newsletter")
if not frappe.db.exists("Role", "Newsletter Manager"):
frappe.get_doc({"doctype": "Role", "role": "Newsletter Manager"}).insert()
for userrole in frappe.get_all("UserRole", "parent", {"role": "Sales Manager"}):
2015-03-24 06:28:21 +00:00
if frappe.db.exists("User", userrole.parent):
user = frappe.get_doc("User", userrole.parent)
2015-03-25 10:25:09 +00:00
user.append("user_roles", {
"doctype": "UserRole",
"role": "Newsletter Manager"
})
user.flags.ignore_mandatory = True
user.save()
# create default lists
general = frappe.new_doc("Newsletter List")
general.title = "General"
general.insert()
general.import_from("Lead")
general.import_from("Contact")