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': "['|','|','|',('request_status','in',['new','cancel']),'&',('user_status','==',False),('has_access_to_request','==',False),'&',('disable_cancellation','=',True),('request_status','=','approved'), ('request_owner_id', '!=', uid)]"}"
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 groups
attribute to restrict the button to admin users
Example:
groups="base.group_erp_manager"