My concept is that I have 5 different access level on Odoo.
I want to check if login user is in list (list is created by an automated action), if yes show the fields else hide them.
My code:
list_of_users= []
if record.user_id.partner_id.id: #level 1 user add on list
list_of_users.append(record.user_id.partner_id.id)
if record.user_id.sale_team_id.user_id.partner_id.id: #level 2 user add on list
list_of_users.append(record.user_id.sale_team_id.user_id.partner_id.id)
if record.user_id.sale_team_id.regional_manager_id.partner_id.id: #level 3 user add on list
list_of_users.append(record.user_id.sale_team_id.regional_manager_id.partner_id.id)
user_ids = record.env['res.users'].search([])
flag = record.env['res.users'].search([('groups_id','ilike','L4')])
for user_ids in flag: #level 4 and 5 users add on list
user_record = record.env['res.users'].browse(user_ids)
list_of_users.append(user_ids.partner_id.id)
record.update({'x_partner_follower_custom': [(6, 0, list_of_users)]})
On view i use attrs="{'invisible': [('x_partner_follower_custom', '=', False)]}"
inside on fields i want to show/hide
x_partner_follower_custom
: many2many res.partner field
As you can see im return users back to view, but it seems the attrs
is not properly set. Any idea how to fix it?
res.partner
model what code should apply on compute field? Image – Fotic