Hiding view elements and menus based on groups
We covered how to hide fields from some users using group parameters in the Python field declaration in previous recipes. Another method for hiding fields in the user interface is to add security groups to the XML elements in the view specification. You may also conceal security groups from a certain user by using menus.
Getting ready
For this recipe, we will reuse the my_hostel
add-on module from the previous recipe. In the previous recipe, we added a button to the <header>
tag. We will hide that whole header from a few users by adding a group attribute to it.
Add the model, the views, and the menus for the hostel.room.category
model. We will hide the category menus from a user. Please refer to Chapter 4, Application Models, to learn how to add model views and menus.
How to do it...
Follow these steps to hide elements based on security groups:
- Add a
groups
attribute to the<header>
tag to hide it from...