Skip to Content
Menu
This question has been flagged
1 Reply
3754 Views

I want to hide the edit button from a form view for a specific user or group, I am able to do it using the access control list by removing the permission to write on the model but it is causing to restrict the write permissions from where which is not the case?

Avatar
Discard

Hi Azlan, did you find the answer about this?

Best Answer

The basic Odoo approach is not to hide an element for a user group, but the opposite - to show an element.

To that end you should just add the attribute 'groups' to the xml view. For example, to show the button only for Odoo admins:

               <button name="do_some_stuff
                        type="object"
                        string="Do some stuff"
                        class="oe_stat_button"
                        icon="fa-line-chart"
                        groups="base.group_erp_manager"
                />

Otherwise, you would need to have the special field which would be calculated based on user groups, and apply the xml 'attrs property. E.g.:

            <field name="your_property" invisible="1"/> 
            <!-- the field 'your_property' should be a computed field, which is calculated based on self.env.user groups --> 
            <button name="do_some_stuff
                        type="object"
                        string="Do some stuff"
                        class="oe_stat_button"
                        icon="fa-line-chart"
                        attrs="{'invisible': [('your_property', '=', True]}"

             />
Avatar
Discard