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
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import collections
|
|
import odoo.http
|
|
|
|
from odoo.http import JsonRPCDispatcher, serialize_exception
|
|
from odoo.addons.iot_drivers.tools.system import IS_TEST
|
|
from werkzeug.exceptions import Forbidden
|
|
|
|
|
|
class JsonRPCDispatcherPatch(JsonRPCDispatcher):
|
|
def handle_error(self, exc: Exception) -> collections.abc.Callable:
|
|
"""Monkey patch the handle_error method to add HTTP 403 Forbidden
|
|
error handling.
|
|
|
|
:param exc: the exception that occurred.
|
|
:returns: a WSGI application
|
|
"""
|
|
error = {
|
|
'code': 200, # this code is the JSON-RPC level code, it is
|
|
# distinct from the HTTP status code. This
|
|
# code is ignored and the value 200 (while
|
|
# misleading) is totally arbitrary.
|
|
'message': "Odoo Server Error",
|
|
'data': serialize_exception(exc),
|
|
}
|
|
if isinstance(exc, Forbidden):
|
|
error['code'] = 403
|
|
error['message'] = "403: Forbidden"
|
|
error['data'] = {"message": error['data']["message"]} # only keep the message, not the traceback
|
|
|
|
return self._response(error=error)
|
|
|
|
|
|
if not IS_TEST:
|
|
# Test IoT system is expected to handle Odoo database unlike "real" IoT systems.
|
|
|
|
def db_list(force=False, host=None):
|
|
return []
|
|
|
|
odoo.http.db_list = db_list
|