Odoo Help

0

How can I make a menuitem only for base.group_sale_manager visible?

By
wizardz
on 7/8/16, 7:39 AM 1,112 views

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"/>

Title of question is: "How can I make a **button** only for base.group_sale_manager visible?", even in question text you refer to **button**, and as you posted a code it appears that actually you're asking about menuitem and NOT about a button. Please correct your question title and a question itself, to make it clear what is it about. My answer below is for a button, not for a menuitem.

Temur
on 7/8/16, 2:56 PM
1

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11594
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 7/8/16, 2:12 PM

Hi,

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.

def fields_view_get(...):
# super call
# check if sales manager group is assigned to current user
# if not, hide the button (add invisible modifier to button)

 How to add modifiers?

0

Temur

--Temur--

3107
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 7/8/16, 9:33 AM

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")

@api.multi
def compute_is_sales_manager(self):
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.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 7/8/16, 7:39 AM
Seen: 1112 times
Last updated: 7/11/16, 2:10 AM