Odoo Help

Welcome!

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

4

Hide menu for existing group

By
Alexander
on 5/28/13, 7:58 AM 19,043 views

How can I hide menu item for user group, using xml? I'm find code example, what grant access for some group:

<record id="original_module.menu_id" model="ir.ui.menu">
    <field name="groups_id" eval="[(4,ref('my_new_group_id'))]"/>
</record>

But, if user group already there, how can I remove it from there?

This question has been included in the official documentation.
21

Omal Bastin

--Omal Bastin--
1146
| 6 6 8
Kochi, Kerala, India
--Omal Bastin--

Swiming deep into openERP/ODOO

Omal Bastin
On 5/28/13, 8:08 AM

you can use the following example

<record id="original_module.menu_id" model="ir.ui.menu">
    <field name="groups_id" eval="[(3,ref('my_new_group_id'))]"/>
</record>

There are actually0-6 numbers for representing each job for a many2many/ one2many field

  • (0, 0, { values }) -- link to a new record that needs to be created with the given values dictionary
  • (1, ID, { values }) -- update the linked record with id = ID (write values on it)
  • (2, ID) -- remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
  • (3, ID) -- cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
  • (4, ID) -- link to existing record with id = ID (adds a relationship)
  • (5) -- unlink all (like using (3,ID) for all linked records)
  • (6, 0, [IDs]) -- replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

Thanks, it's works fine for me. May be you can explain what mean '4' and '3' numbers?

Alexander
on 5/28/13, 9:17 AM

I have updated my answer. please check it as correct answer, if you feel its correct. Thank you

Omal Bastin
on 5/29/13, 3:57 AM

Thank you for your help. Where did you find this information?

Alexander
on 5/29/13, 4:47 AM

I havent find any online documents. i found this in the orm file openerp addons

Omal Bastin
on 6/3/13, 5:10 AM

good work Omal. thanks! that help me a lot.

ARRIOUACH Mohamed
on 11/7/14, 9:38 AM

THANKS!

Pascal Tremblay
on 1/13/15, 8:14 AM

For existing groups i can hide menu but for new group (group i created), i am unable to hide menu.

Vardan
on 1/22/16, 5:51 AM
This question has been included in the official documentation.
0
Omi Harjani
On 11/17/16, 11:34 PM
<record id="base.menu_base_partner" model="ir.ui.menu">    <field name="groups_id" eval="[(5,ref('base.group_hidden'))]"/></record><record id="account.menu_finance" model="ir.ui.menu">    <field name="groups_id" eval="[(5,ref('base.group_hidden'))]"/></record>	<menuitem icon="terp-account" id="account.menu_finance" name="Accounting" sequence="14" action="account.open_board_account" groups="base.group_hidden"/>			<menuitem icon="terp-partner"			            id="base.menu_base_partner" name="Sales"			            sequence="1" groups="base.group_hidden"/>	<menuitem id="sales_branch.menu_branch_sale_quotation" name="Sales" groups="base.group_sales_manager"/>
This question has been included in the official documentation.
0
bernscheinder
On 7/29/14, 3:29 AM

Hi,

I've tried this example:

<record id="view_picking_out_form_stoking" model="ir.ui.view">
            <field name="name">stock.picking.form.stocking</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="groups_id" eval="[(6,0,[ref('stoking.res_groups_fournisseur')])]"/>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <xpath expr="/form[@string='Delivery Orders']/group/group/field[@name='date']" position="attributes">
                    <attribute name="attrs">{'readonly':[('state','not in',['cancel'])]}</attribute>
                </xpath>
                <xpath expr="/form[@string='Delivery Orders']/group/group/field[@name='min_date']" position="attributes">
                       <attribute name="attrs">{'readonly':[('state','not in',['cancel'])]}</attribute>
                </xpath>  
                <xpath expr="/form[@string='Delivery Orders']/group/group/field[@name='address_id']" position="attributes">
                       <attribute name="attrs">{'readonly':[('state','not in',['cancel'])]}</attribute>
                </xpath>
                <xpath expr="/form[@string='Delivery Orders']/notebook/page[@string='Notes']/field[@name='note']" position="attributes">
                       <attribute name="attrs">{'readonly':[('state','not in',['cancel'])]}</attribute>
                </xpath>   
            </field>
       </record>

 

But all groups is in read only. My goal is that "res_groups_fournisseur" only is in readolny in these fields.

This question has been included in the official documentation.
0
wilson zauma
On 3/13/14, 5:11 PM

i like to hide a menu for one group specifity, but when i apply delete this remove all menu for all users, but i want to hide for one groups. explain: i inherit a groups to user from warehouse, but this specifity users i dont want to show menu stock out.

for example i create a new groups users. i define in MY_module_folder/security/my_security.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
 <data noupdate="0">
    <record id="group_stock_manager_moseltex" model="res.groups">
        <field name="name">Almacen_mosel Encargado</field>
       <field name="implied_ids" eval="[(4, ref('stock.group_stock_manager'))]"/>
    </record>
    <record id="group_stock_user_moseltex" model="res.groups">
        <field name="name">Almacen_mosel usuario</field>
        <field name="category_id" ref="base.module_category_warehouse_management"/>
        <field name="implied_ids" eval="[(4, ref('stock.group_stock_user'))]"/>
    </record>
 </data>
</openerp>

but i want to hide a menu stock out (this code put inside the my_security.xml).

 <record model="ir.ui.menu" id="menu_action_picking_tree">
 <field name="groups_id"  eval="[ref('group_stock_manager_moseltex')]" />

but this is dont work.

i try to use this code, i think that this hide the menu for the users but this is no work.

<field name="groups_id" eval="[(3, ref('group_stock_users_moseltex'))]"/>
This question has been included in the official documentation.
0
Alcaline
On 10/21/14, 9:51 AM

hi

I want to hide my menu in Human Resources? I used that groups but it didn't work? can anyone please help me how to solve this problem thanks in advance..

Here is my code:

     <menuitem name="Human Resources"
            id="menu_hr_root"
            groups="base.group_hr_manager,base.group_hr_user,base.group_user"
            sequence="90"/>
        <menuitem id="menu_hr_main" parent="menu_hr_root" name="Human Resources" sequence="0"/>
        <menuitem id="menu_hr_configuration" name="Configuration" parent="hr.menu_hr_root" groups="base.group_hr_manager" sequence="50"/>

Your Answer

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

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

6 follower(s)

Stats

Asked: 5/28/13, 7:58 AM
Seen: 19043 times
Last updated: 11/17/16, 11:34 PM