Files
Yamen Ahmad 3e83d8d7d5 feat: add complete EnCoach backend — Odoo 19 + all addons
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
2026-04-01 17:10:04 +04:00

35 lines
1.5 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import http
from odoo.fields import Domain
from odoo.http import request
from odoo.addons.mail.tools.discuss import add_guest_to_context, Store
class SearchController(http.Controller):
@http.route("/discuss/search", methods=["POST"], type="jsonrpc", auth="public")
@add_guest_to_context
def search(self, term, category_id=None, limit=10):
store = Store()
self.get_search_store(store, search_term=term, limit=limit)
return store.get_result()
def get_search_store(self, store: Store, search_term, limit):
base_domain = Domain("name", "ilike", search_term) & Domain("channel_type", "!=", "chat")
priority_conditions = [
Domain("is_member", "=", True) & base_domain,
base_domain,
]
channels = self.env["discuss.channel"]
for domain in priority_conditions:
remaining_limit = limit - len(channels)
if remaining_limit <= 0:
break
# We are using _search to avoid the default order that is
# automatically added by the search method. "Order by" makes the query
# really slow.
query = channels._search(Domain('id', 'not in', channels.ids) & domain, limit=remaining_limit)
channels |= channels.browse(query)
store.add(channels)
request.env["res.partner"]._search_for_channel_invite(store, search_term=search_term, limit=limit)