How can I make a menuitemonly for base.group_sale_manager visible?
for example this:
if I make this, the other user with " only own leads " rights can see the menuitem only.
<menuitem id="real_menu_second_2" parent="section_main_menu_1" groups="base.group_sale_manager" action="button_action_addon"/>
You can do it by overriding fields_view_get() method. In this method you just have to check if sales manager group is assigned (using has_group() method of res.users object) to current user or not. If not then hide the button.
# super call
# check if sales manager group is assigned to current user
# if not, hide the button (add invisible modifier to button)
You can use computed Boolean field for that, include this field in your view as invisible="1" and make the button invisible depending on the value of the Boolean field. Here is the Boolean field itself:
is_sales_manager = fields.Booelan("Sales Manager", compute="compute_is_sales_manager")
is_manager = self.env.user.has_group("base.group_sale_manager")
for rec in self:
rec.is_sales_manager = is_manager
so, if you make the button invisible depending on this Boolean field, then it should be visible only to users who belong to the "base.group_sale_manager" group.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 7/8/16, 7:39 AM|
|Seen: 348 times|
|Last updated: 7/11/16, 2:10 AM|