2015-03-18 14:32:44 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2019-01-22 12:52:20 +00:00
|
|
|
from __future__ import unicode_literals
|
2015-03-18 14:32:44 +00:00
|
|
|
import frappe
|
2015-03-20 04:59:30 +00:00
|
|
|
import frappe.permissions
|
2015-03-18 14:32:44 +00:00
|
|
|
|
|
|
|
def execute():
|
2015-03-27 05:19:41 +00:00
|
|
|
frappe.reload_doc("core", "doctype", "block_module")
|
2015-03-18 14:32:44 +00:00
|
|
|
frappe.reload_doctype("User")
|
|
|
|
frappe.reload_doctype("Lead")
|
|
|
|
frappe.reload_doctype("Contact")
|
|
|
|
|
2016-06-28 05:47:02 +00:00
|
|
|
frappe.reload_doc('email', 'doctype', 'email_group')
|
|
|
|
frappe.reload_doc('email', 'doctype', 'email_group_member')
|
|
|
|
frappe.reload_doc('email', 'doctype', 'newsletter')
|
2015-03-18 14:32:44 +00:00
|
|
|
|
2015-03-20 04:59:30 +00:00
|
|
|
frappe.permissions.reset_perms("Newsletter")
|
2015-03-18 14:32:44 +00:00
|
|
|
|
|
|
|
if not frappe.db.exists("Role", "Newsletter Manager"):
|
|
|
|
frappe.get_doc({"doctype": "Role", "role": "Newsletter Manager"}).insert()
|
|
|
|
|
2017-02-20 09:41:56 +00:00
|
|
|
for userrole in frappe.get_all("Has Role", "parent", {"role": "Sales Manager", "parenttype": "User"}):
|
2015-03-24 06:28:21 +00:00
|
|
|
if frappe.db.exists("User", userrole.parent):
|
|
|
|
user = frappe.get_doc("User", userrole.parent)
|
2017-02-20 09:08:49 +00:00
|
|
|
user.append("roles", {
|
2017-02-20 09:41:56 +00:00
|
|
|
"doctype": "Has Role",
|
2015-03-25 10:25:09 +00:00
|
|
|
"role": "Newsletter Manager"
|
|
|
|
})
|
|
|
|
user.flags.ignore_mandatory = True
|
|
|
|
user.save()
|
2015-03-18 14:32:44 +00:00
|
|
|
|
|
|
|
# create default lists
|
2016-06-28 05:47:02 +00:00
|
|
|
general = frappe.new_doc("Email Group")
|
2015-03-18 14:32:44 +00:00
|
|
|
general.title = "General"
|
|
|
|
general.insert()
|
|
|
|
general.import_from("Lead")
|
|
|
|
general.import_from("Contact")
|