Includes: - Odoo 19 framework (odoo/) - 27 custom EnCoach addons (new_project/custom_addons/) - encoach_core, encoach_api, encoach_lms_api, encoach_adaptive_api - encoach_exam, encoach_taxonomy, encoach_adaptive, encoach_assignment - encoach_ai, encoach_ai_grading, encoach_ai_generation, encoach_ai_media - encoach_courseware, encoach_communication, encoach_subscription - encoach_notification, encoach_approval, encoach_branding - encoach_classroom, encoach_registration, encoach_stats - encoach_faq, encoach_ticket, encoach_training, encoach_resources - encoach_adaptive_ai, encoach_sis - 21 OpenEduCat Enterprise modules (new_project/enterprise-19/) - 14 OpenEduCat Community modules (new_project/openeducat_erp-19.0/) - Configuration: odoo.conf, requirements.txt, scripts - 200+ REST API endpoints with JWT authentication - SRS and test documentation Made-with: Cursor
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models
|
|
from odoo.fields import Domain
|
|
from odoo.http import request
|
|
|
|
SKIP_CAPTCHA_LOGIN = object()
|
|
|
|
|
|
class ResUsers(models.Model):
|
|
_inherit = "res.users"
|
|
|
|
@api.model
|
|
def name_search(self, name='', domain=None, operator='ilike', limit=100):
|
|
# if we have a search with a limit, move current user as the first result
|
|
domain = Domain(domain or Domain.TRUE)
|
|
user_list = super().name_search(name, domain, operator, limit)
|
|
uid = self.env.uid
|
|
# index 0 is correct not Falsy in this case, use None to avoid ignoring it
|
|
if (index := next((i for i, (user_id, _name) in enumerate(user_list) if user_id == uid), None)) is not None:
|
|
# move found user first
|
|
user_tuple = user_list.pop(index)
|
|
user_list.insert(0, user_tuple)
|
|
elif limit is not None and len(user_list) == limit:
|
|
# user not found and limit reached, try to find the user again
|
|
if user_tuple := super().name_search(name, domain & Domain('id', '=', uid), operator, limit=1):
|
|
user_list = [user_tuple[0], *user_list[:-1]]
|
|
return user_list
|
|
|
|
def _on_webclient_bootstrap(self):
|
|
self.ensure_one()
|
|
|
|
def _should_captcha_login(self, credential):
|
|
if request and request.env.context.get('skip_captcha_login') is SKIP_CAPTCHA_LOGIN:
|
|
return False
|
|
return credential['type'] == 'password'
|