Odoo Help

3

Correct way to modify existing menuitems their groups and position?

By
Yenthe
on 11/17/15, 6:01 AM 1,842 views

Hi guys,

I've been trying for a while to do this correctly now but couldn't find a correct way that does exactly what it should. The default menuitem 'Quotations' under Sales > Quotations should only be accessible for the group 'group_sale_manager' only and the same thing should be done for the menuitem 'Sales Orders' under Sales. My last attempt:

 <menuitem name="Quotations" 
id="sale.menu_sale_quotations"
parent="base.menu_sales"
groups="base.group_sale_manager"/> <menuitem name="Sales Orders" id="sale.menu_sale_order" parent="base.menu_sales" groups="base.group_sale_manager"/>

Somehow this seems to work for Quotations but not for Sales Orders. What am I doing wrong or missing? Another thing that I was wondering is how to move an existing menuitem ('Customers' under Sales) to another section in the sale module. I've created a new menuitem:

<!--Creates a new top menuitem named 'SEL' --> 
<menuitem id="base.menu_sel" name="SEL" parent="base.menu_base_partner" groups="aa_module.group_sel_manager" sequence="1"/>

So how do I move the menuitem 'Customers' under the menuitem 'SEL' in place of under 'Sales'?

Thanks,
Yenthe

Remember to always check your modification on account othr than Admin. Admin is sees everything so, create new users with and without group_sale_manager access rights, and then check if everything works.

devza
on 11/17/15, 6:41 AM

Thanks for your response Tobiasz. It does seem to work for the menuitem Quotations but not for Sales Orders but I don't know why. It is exactly the same code.

Yenthe
on 11/17/15, 7:27 AM

The menu Sale Orders have that group by default

Axel Mendoza
on 11/17/15, 7:49 AM
3
Axel Mendoza
On 11/17/15, 7:45 AM

I copy and paste your menuitem def and the Quotations menu get the group ok, as @Tobiasz saids check agains a user that doesn't have the group. You could also try this way:

<record model='ir.ui.menu' id='sale.menu_sale_quotations'>
<field name="groups_id" eval="[(4,ref('base.group_sale_manager'))]"/>
</record>

Also you need to check that the user that you are using to test this does not have a group assigned that inherit from base.group_sale_manager

For the menu position all depends of the sequence field so if you vary the value of that field to a value lesser than or higher than another menu sequence value the menu will be moved.

Always after a change in the menus you need to refresh the page because the menu need to reload

Hope this helps

=================================update========================================

The menu for sale orders by default have defined the groups: "base.group_sale_salesman" and "base.group_sale_manager". To left only the group "base.group_sale_manager" redefine it like this in your module:

<menuitem name="Sales Orders" id="sale.menu_sale_order" parent="base.menu_sales" groups="-base.group_sale_salesman"/>

Notice the - sign before the group name

@Axel thanks for your answer! the thing is that the 'Quotations' menuitem is indeed gone but somehow it doesn't work for the 'Sales Orders' and I have no idea why. I'm testing this on a new user with just the rights 'user' for sales. Could you give my second menuitem a try too please?

Yenthe
on 11/17/15, 7:52 AM

The default menu definition in the sale module have this two groups by default:
base.group_sale_salesman
base.group_sale_manager
You don't need to define it again

Axel Mendoza
on 11/17/15, 7:55 AM

@Axel it should only be accessible for the users in the group 'base.group_sale_manager' and not for 'base.group_sale_salesman' as it is by default.

Yenthe
on 11/17/15, 7:58 AM

check the update in the answer

Axel Mendoza
on 11/17/15, 8:09 AM

That is amazing! I didn't even know you could invoke access rights with the '-'! Accepted & upvoted, thanks Axel.

Yenthe
on 11/17/15, 8:29 AM

Happy to help

Axel Mendoza
on 11/17/15, 7:07 PM

Hi Axel I try as per your code.... not working ...I need this same scenario

Odoo
on 4/13/16, 1:33 AM

I tried this way no effect..

Odoo
on 4/13/16, 1:37 AM
Odoo
on 4/13/16, 1:39 AM
0
Odoo
On 4/13/16, 1:40 AM

I tried like axel suggestion but not changing........


<record model='ir.ui.menu' id='sale.menu_sale_quotations'>     <field name="groups_id" eval="[(4,ref('base.group_sale_salesman'))]"/></record>      <record model='ir.ui.menu' id='sale.menu_sale_order'>     <field name="groups_id" eval="[(4,ref('base.group_sale_salesman'))]"/></record>

Hi Dep. Yours it's not the same scenario described in the solution of this thread

Axel Mendoza
on 4/17/16, 11:15 AM

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

3 follower(s)

Stats

Asked: 11/17/15, 6:01 AM
Seen: 1842 times
Last updated: 7/18/17, 5:34 AM