I have a requirement that I have a sub-admin who is able to create new users but with only available specific roles, the sub-admin will only see the roles that top level admin wanted him to see.
My problem is related to the following topic
Is there any method to hide roles from User doctype from this HTML roles!
In my system, I want to make a new user with administrator permission(System Manager) expect some modules roles that it mustn’t appear to the user so he can not able to take them.
Is there any method to make this !
If I remove unwanted roles from tabRole is this a good solution ?!
Is there anyway we could achieve that. Otherwise I am thinking to have client script on user doctype that will hide all the uncessary roles from the list.
I also want to hide uncessary modules from allow module section.
Thank you in anticipation.
override whiltelist method get_all_roles
change from get_all to get_list
add user permissions for sub-admin user, allow Role, value as allowed roles.
Thank you for the response.
Can you please share where to override the method? In .py file of doctype?
and get_list_roles is a predefined method?
@szufisher Thank you for the help.
I did the both things you mentioned.
The “roles” section break in the user doctype is not showing when I am creating and editing user from sub-admin. I have allowed one role in user permission of sub-admin to allow to the created user. but there is not roles section break from where I could select the role to assign the newly created user.
looking for same solution
I have turned on the System Manager role on the sub-admin now I can see the roles section. Let me see which permission on the System Manager allowing it to show.
sure will share the results working on this.
adding the following permission to sub-admin role showed the roles section in user doctype.
I am done with showing specific roles for the users to the sub-admin with the help you have provided.
Can you please guide that how to show only specific modules to sub-admin for the users in “Allow Modules” section?
to show specific modules,
I have followed the same strategy, I have changed the method from get_all to get_list in the following file
kindly suggest, is this the right way to show specific modules?
Now I am stuck, after creating the user only specified modules are showing but all the modules are checked true behind the scene, so now I want all the modules need to be unchecked by default.