21 lines
663 B
Python
21 lines
663 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import api, models
|
|
|
|
|
|
class ResUsers(models.Model):
|
|
_inherit = "res.users"
|
|
|
|
@api.model
|
|
def name_search(self, name="", args=None, operator="ilike", limit=100):
|
|
args = list(args or [])
|
|
group_ids = self.env.context.get("nxz_deputy_group_ids")
|
|
if group_ids:
|
|
self.env.cr.execute(
|
|
"SELECT uid FROM res_groups_users_rel WHERE gid IN %s",
|
|
(tuple(group_ids),),
|
|
)
|
|
uids = [row[0] for row in self.env.cr.fetchall()]
|
|
args.append(("id", "in", uids or [0]))
|
|
return super().name_search(name, args, operator, limit=limit)
|