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 个解决方案
#1
4
you could try:
你可以尝试:
fields.Many2one('res.user',string="Admins", domain=[('groups_id','in',[12])])
I hope this help you
我希望这对你有帮助
#2
2
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 )] )
#1
4
you could try:
你可以尝试:
fields.Many2one('res.user',string="Admins", domain=[('groups_id','in',[12])])
I hope this help you
我希望这对你有帮助
#2
2
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 )] )