Skip to Content
Menu
This question has been flagged

Hi, I have a model of incidents with this field:-


team_ids = fields.Many2many( 'moderation.team', relation='incident_incident_moderation_team_rel', string='Moderation Teams',        column1='incident_incident_ids', column2='moderation_team_ids', ondelete='restrict', required=True)​

And each logged in user will have a field called 'team_ids' that contains the teams that they are assigned to. 

team_ids = fields.Many2many('moderation.team', relation='res_users_moderation_team_rel',         column1='res_user_ids', column2='moderation_team_ids')

Now I want to create a record rule in the security.xml that will allow only those users who have in their 'user.team_ids' field, at least one of the team_ids that has been assigned to the incident record. 

I've tried a few things but my problem is that I don't understand the structure of these data types and I'm struggling. How do I write this record rule?

Avatar
Discard
Author Best Answer

I ended up getting it to work by using the '=' instead of 'in' operator.

Avatar
Discard
Best Answer

I think you'll need something like this (from mail.mail_channel_rule):

('group_public_id', 'in', [g.id for g in user.groups_id])

You'll need to adapt this for your own Models.

Avatar
Discard
Related Posts Replies Views Activity
1
Oct 22
6458
1
Mar 15
4352
2
Mar 24
1523
1
Mar 15
6245
0
Sep 23
1744