How to use attrs invisible (Odoo 14)

Viewed 1186

I want to show field only for the administrator using attrs invisible.

<record id="users_form" model="ir.ui.view">
            <field name="name">users_form</field>
            <field name="model">res.users</field>
            <field name="inherit_id" ref="base.view_users_form"/>
            <field name="arch" type="xml">
                    <group string="Gp">
                         <field name="field1"/>
                    </group>
            </field>
        </record>

Thanks.

1 Answers

you could use groups attribute in your field tag as following:

<field name="field1" groups="base.group_user"/>

or for muliple groups, you could add them using comma separated group xml id

<field name="field1" groups="base.group_user,base.group_multi_company"/>

or you could add field tag for each group in some cases, in case you need different attrs for each group:

<field name="field1" groups="base.group_user" attrs="{'readonly': [('condition', '=', True)]}"/>
<field name="field1" groups="base.group_multi_company" attrs="{'required': [('condition', '=', True)]}"/>
Related