Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
13 Antwoorden
59442 Weergaven

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?

Avatar
Annuleer
Beste antwoord

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)
Avatar
Annuleer
Auteur

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

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

Auteur

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

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

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

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

Thank you for the very clear and explicit answer!

This is not working for me. I used 3 and 5 to unlink a user from a menu which is basically public to every one

Beste antwoord

https://youtu.be/zHPtb1SR8Sk

Avatar
Annuleer
Beste antwoord
<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"/>
Avatar
Annuleer
Beste antwoord

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'))]"/>
Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Beste antwoord

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.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
mei 22
2141
1
aug. 20
5181
0
mei 19
3318
1
sep. 17
8195
1
jul. 16
9312