Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
5582 Zobrazení

Hello guys.

I want a Many2many field that get all the users that belongs to a specific group. I have something like this but is not working, can you help me please?


managers = fields.Many2many('res.users', string="Users in charge",
default=lambda self: self.env.ref("custom_module.group_pos").id)
Avatar
Zrušit
Nejlepší odpověď

Hi 21m,

Please try this code:

managers = fields.Many2many(
'res.users', string="Users in charge",
default=lambda self: self.env.ref("custom_module.group_pos").users.ids)

Please vote the answer if it helps you.

Thanks

Avatar
Zrušit
Nejlepší odpověď
def _default_res_users(self):
    users_obj = self.env['res.users']
users = []
for user in users_obj.search([]):
if user.has_group("custom_module.group_pos"):
         users.append(user.id)
return users
managers = fields.Many2many('res.users', string="Users in charge",
default=_default_res_users)

Try This.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
dub 24
1156
1
kvě 23
3844
2
čvc 22
4446
3
pro 21
4186
5
zář 23
48828