Hiding view elements and menus based on groups
In the previous recipes, we've learned how to hide fields from some users with group arguments in the Python field definition. There is another way to hide fields in the user interface: by adding security groups to the XML tags in the view definition. You can also use security groups with menus to hide them from a particular user.
For this recipe, we will reuse the
my_library 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 groups attribute to it.
Add the model, the views, and the menus for the
book.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 in security groups:
- Add a groups attribute to the
<header>tag to hide...