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 10:29:30 +05:30
import frappe.permissions
def execute():
2015-03-27 10:49:41 +05:30
frappe.reload_doc("core", "doctype", "block_module")
frappe.reload_doctype("User")
frappe.reload_doctype("Lead")
frappe.reload_doctype("Contact")
2016-06-28 11:17:02 +05:30
frappe.reload_doc('email', 'doctype', 'email_group')
frappe.reload_doc('email', 'doctype', 'email_group_member')
frappe.reload_doc('email', 'doctype', 'newsletter')
2015-03-20 10:29:30 +05:30
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("Has Role", "parent", {"role": "Sales Manager", "parenttype": "User"}):
2015-03-24 11:58:21 +05:30
if frappe.db.exists("User", userrole.parent):
user = frappe.get_doc("User", userrole.parent)
2017-02-20 14:38:49 +05:30
user.append("roles", {
"doctype": "Has Role",
2015-03-25 15:55:09 +05:30
"role": "Newsletter Manager"
})
user.flags.ignore_mandatory = True
user.save()
# create default lists
2016-06-28 11:17:02 +05:30
general = frappe.new_doc("Email Group")
general.title = "General"
general.insert()
general.import_from("Lead")
general.import_from("Contact")