Suppose I want to compare the user_id field with the currently logged-in user id. Since we cannot use two field names in the filter, There is a solution here. We can use another field to check this.
Here is an example: We have a field name 'user_check'.
user_check = fields.Boolean('Check User', index=True, compute="_compute_user_check")
@api.depends('user_id', 'current_user_id')
def _compute_user_check(self):
if self.current_user_id == self.user_id:
self.user_check = True
else:
self.user_check = False
If we want to hide a field if the user id does not match with the currently logged-in user id, then in views we will use:
attrs="{'invisible': [('user_check', '=', False)]}"
Hope this will work. Thanks