UID In attrs are not supported. Instead of using the uid field in attrs you can use the computed field.
Solutions.
1. You can use a compute field to update the current user id and compare it in attrs
manager_id = fields.Integer(compute='get_current_uid', string='Manager ID Computed')
def get_current_uid(self):
"""
:param self:
:return:
"""
if self.env.context.get('uid', False):
self.manager_id = self.env.context.get('uid', False)
else:
self.manager_id = False
attrs = "{'invisible': [('state', 'in', ['draft', 'approved', 'rejected']), ('manager.id', '=', computed_field)]}"
2. In ODOO this function(overrided and updated) allows getting uid in attrs.
# Don't deal with groups, it is done by check_group().
# Need the context to evaluate the invisible attribute on tree views.
# For non-tree views, the context shouldn't be given.
def transfer_node_to_modifiers(node, modifiers, context=None, in_tree_view=False):
if node.get('attrs'):
if 'uid' in node.get('attrs'):
if context.get('uid', False):
user_id = str(context.get('uid', False))
attrs = node.get('attrs')
node.set('attrs', attrs.replace('uid', user_id))
else:
user_id = '1'
attrs = node.get('attrs')
node.set('attrs', attrs.replace('uid', user_id))
modifiers.update(eval(node.get('attrs')))
if node.get('states'):
if 'invisible' in modifiers and isinstance(modifiers['invisible'], list):
# TODO combine with AND or OR, use implicit AND for now.
modifiers['invisible'].append(('state', 'not in', node.get('states').split(',')))
else:
modifiers['invisible'] = [('state', 'not in', node.get('states').split(','))]
for a in ('invisible', 'readonly', 'required'):
if node.get(a):
v = bool(eval(node.get(a), {'context': context or {}}))
if in_tree_view and a == 'invisible':
# Invisible in a tree view has a specific meaning, make it a
# new key in the modifiers attribute.
modifiers['tree_invisible'] = v
elif v or (a not in modifiers or not isinstance(modifiers[a], list)):
# Don't set the attribute to False if a dynamic value was
# provided (i.e. a domain from attrs or states).
modifiers[a] = v