3
votes

I am trying to create a drop-down in my custom module form where i want to show users from a specific group

fields.Many2one('res.user',string="Admins", domain=[('groups_id','=',12)])

this is what i tried, adding a domain but it is not working.

I want to show all user who are admins in this drop-down.

2
you have an option in the view called "groups" (e.g. groups="hr_recruitment.group_hr_recruitment_manager"). Is it enough? - dccdany

2 Answers

4
votes

you could try:

fields.Many2one('res.user',string="Admins", domain=[('groups_id','in',[12])])

I hope this help you

3
votes

you can try this:

fields.Many2many( comodel_name = "res.users", string = "admin",domain=lambda self: [("groups_id", "=", self.env.ref( "module_name.group_id" ).id)])

example:

fields.Many2many(comodel_name = "res.users",string="Stock Pickers",domain=lambda self: [( "groups_id", "=", self.env.ref( "stock.group_stock_picker" ).id )] )