mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 02:52:00 +02:00
vanilla 17.0
This commit is contained in:
parent
d72e748793
commit
a9bcec8e91
1986 changed files with 1613876 additions and 568976 deletions
30
odoo-bringout-oca-ocb-web/web/models/res_users.py
Normal file
30
odoo-bringout-oca-ocb-web/web/models/res_users.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
@api.model
|
||||
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
|
||||
user_query = super()._name_search(name, domain, operator, limit, order)
|
||||
if limit is None:
|
||||
return user_query
|
||||
user_ids = list(user_query)
|
||||
if self._uid in user_ids:
|
||||
if user_ids.index(self._uid) != 0:
|
||||
user_ids.remove(self._uid)
|
||||
user_ids.insert(0, self._uid)
|
||||
elif limit and len(user_ids) == limit:
|
||||
new_user_ids = super()._name_search(
|
||||
name,
|
||||
expression.AND([domain or [], [('id', '=', self._uid)]]),
|
||||
operator,
|
||||
limit=1,
|
||||
)
|
||||
if new_user_ids:
|
||||
user_ids.pop()
|
||||
user_ids.insert(0, self._uid)
|
||||
return user_ids
|
||||
Loading…
Add table
Add a link
Reference in a new issue