Help

4

Correct way to modify existing menuitems their groups and position?

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

3 Comments
Avatar
Discard
Avatar
devza
-

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.

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.

Avatar
Axel Mendoza
-

The menu Sale Orders have that group by default

2 Answers
4
Avatar
Axel Mendoza
Best Answer

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

9 Comments
Avatar
Discard

@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?

Avatar
Axel Mendoza
-

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 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.

Avatar
Axel Mendoza
-

check the update in the answer

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

Avatar
Axel Mendoza
-

Happy to help

Avatar
Odoo
-

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

Avatar
Odoo
-

I tried this way no effect..

Avatar
Odoo
-
0
Avatar
Odoo
Best Answer

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>
1 Comment
Avatar
Discard
Avatar
Axel Mendoza
-

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