2016-09-23 16:21:51 +00:00
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
|
|
|
frappe.reload_doctype('Role')
|
|
|
|
for role_name in ('Customer', 'Supplier', 'Student'):
|
|
|
|
if frappe.db.exists('Role', role_name):
|
|
|
|
frappe.db.set_value('Role', role_name, 'desk_access', 0)
|
|
|
|
else:
|
|
|
|
frappe.get_doc(dict(doctype='Role', role_name=role_name, desk_access=0)).insert()
|
|
|
|
|
|
|
|
|
|
|
|
# set customer, supplier roles
|
|
|
|
for c in frappe.get_all('Contact', fields=['user'], filters={'ifnull(user, "")': ('!=', '')}):
|
|
|
|
user = frappe.get_doc('User', c.user)
|
|
|
|
user.set_default_roles()
|
2016-09-23 18:37:31 +00:00
|
|
|
user.flags.ignore_validate = True
|
2016-09-23 18:51:53 +00:00
|
|
|
user.flags.ignore_mandatory = True
|
2016-09-23 16:21:51 +00:00
|
|
|
user.save()
|
|
|
|
|
|
|
|
|