diff --git a/erpnext/domains/manufacturing.py b/erpnext/domains/manufacturing.py index b8bb7e0578..8c911a311d 100644 --- a/erpnext/domains/manufacturing.py +++ b/erpnext/domains/manufacturing.py @@ -18,8 +18,5 @@ data = { 'set_value': [ ['Stock Settings', None, 'show_barcode_field', 1] ], - 'restricted_roles': [ - 'Manufacturing User' - ], 'default_portal_role': 'Customer' } \ No newline at end of file diff --git a/erpnext/patches/v9_0/revert_manufacturing_user_role.py b/erpnext/patches/v9_0/revert_manufacturing_user_role.py new file mode 100644 index 0000000000..5bfa8c3f9a --- /dev/null +++ b/erpnext/patches/v9_0/revert_manufacturing_user_role.py @@ -0,0 +1,21 @@ +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()