brotherton-erpnext/erpnext/patches/v9_0/revert_manufacturing_user_role.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
601 B
Python
Raw Normal View History

from __future__ import unicode_literals
import frappe
def execute():
if 'Manufacturing' in frappe.get_active_domains(): return
role = 'Manufacturing User'
frappe.db.set_value('Role', role, 'restrict_to_domain', '')
frappe.db.set_value('Role', role, 'disabled', 0)
users = frappe.get_all('Has Role', filters = {
'parenttype': 'User',
'role': ('in', ['System Manager', 'Manufacturing Manager'])
}, fields=['parent'], as_list=1)
for user in users:
_user = frappe.get_doc('User', user[0])
_user.append('roles', {
'role': role
})
_user.flags.ignore_validate = True
_user.save()