تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5815 أدوات العرض

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)
الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
أفضل إجابة
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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أبريل 24
1340
1
مايو 23
4091
2
يوليو 22
4683
3
ديسمبر 21
4474
5
سبتمبر 23
49361