Odoo 15: How to check if current user is admin in view

I am working with approvals in Odoo and I am trying to replace action_cancel button. This is my code currently:

<button name="action_cancel" string="Cancel" type="object"
                    attrs="{'invisible': &quot;['|','|','|',('request_status','in',['new','cancel']),'&amp;',('user_status','==',False),('has_access_to_request','==',False),'&amp;',('disable_cancellation','=',True),('request_status','=','approved'), ('request_owner_id', '!=', uid)]&quot;}"
                    data-hotkey="z" />

I also want to check if currently logged in user is admin. I have not found a way how to use environment method .is_admin(). Is there any way how to do this? I cannot use template directives and would like to avoid creating special field that will only check if the current user is admin.


  • _is_admin function will check if the user id is equal to the SUPERUSER_ID or belongs to the Administration/Access Rights group

    You can use groupsattribute to restrict the button to admin users