From efe2ffa2995e3d6b45765ad7db4dc6d0194a182a Mon Sep 17 00:00:00 2001 From: Nikos Tsirintanis Date: Wed, 15 Apr 2026 12:47:15 +0200 Subject: [PATCH 1/4] [FIX] sentry: handle early post_load when http server is not ready (cherry picked from commit 71015b82a4804d47f3ff58263456808f208fcf98) --- sentry/hooks.py | 26 +++++++++++-- sentry/tests/test_client.py | 73 ++++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 5 deletions(-) diff --git a/sentry/hooks.py b/sentry/hooks.py index 6a6af920967..eb1ee9bc6c8 100644 --- a/sentry/hooks.py +++ b/sentry/hooks.py @@ -19,6 +19,7 @@ _logger = logging.getLogger(__name__) HAS_SENTRY_SDK = True +_ORIGINAL_APPLICATION_CALL = None try: import sentry_sdk from sentry_sdk.integrations.logging import ignore_logger @@ -136,12 +137,29 @@ def initialize_sentry(config): for item in exclude_loggers: ignore_logger(item) - # The server app is already registered so patch it here - if server: + global _ORIGINAL_APPLICATION_CALL + + # The server app is already registered so patch it here. + # this is mostly a defensive fallback + if server and server.app is not odoo.http.root: server.app = SentryWsgiMiddleware(server.app) - # Patch the wsgi server in case of further registration - odoo.http.Application = SentryWsgiMiddleware(odoo.http.Application) + # Patch the actual WSGI entrypoint while keeping + # odoo.http.Application as a class + # odoo.http.root as the regular root/application object + if _ORIGINAL_APPLICATION_CALL is None: + _ORIGINAL_APPLICATION_CALL = odoo.http.Application.__call__ + + def sentry_application_call(self, environ, start_response): + middleware = getattr(self, "_sentry_wsgi_middleware", None) + if middleware is None: + middleware = SentryWsgiMiddleware( + _ORIGINAL_APPLICATION_CALL.__get__(self, type(self)) + ) + self._sentry_wsgi_middleware = middleware + return middleware(environ, start_response) + + odoo.http.Application.__call__ = sentry_application_call with sentry_sdk.new_scope() as scope: scope.set_extra("debug", False) diff --git a/sentry/tests/test_client.py b/sentry/tests/test_client.py index e506582caad..e25d50cac7b 100644 --- a/sentry/tests/test_client.py +++ b/sentry/tests/test_client.py @@ -1,13 +1,16 @@ # Copyright 2016-2017 Versada +# Copyright 2026 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - +import inspect import logging import sys from unittest.mock import patch from sentry_sdk.integrations.logging import _IGNORED_LOGGERS +from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware from sentry_sdk.transport import HttpTransport +import odoo.http from odoo import exceptions from odoo.tests import TransactionCase from odoo.tools import config @@ -266,3 +269,71 @@ def test_config_release(self, get_odoo_commit): RELEASE, "Failed to use 'sentry_release' parameter appropriately", ) + + def test_initialize_sentry_patches_application_call_when_server_missing(self): + original_root = odoo.http.root + original_application = odoo.http.Application + + class DummyRoot: + def __init__(self): + self.session_store = object() + + class DummyApplication: + def __call__(self, environ, start_response): + return "ok" + + try: + dummy_root = DummyRoot() + original_call = DummyApplication.__call__ + odoo.http.root = dummy_root + odoo.http.Application = DummyApplication + with ( + patch("odoo.addons.sentry.hooks.server", new=None), + patch("odoo.addons.sentry.hooks._ORIGINAL_APPLICATION_CALL", new=None), + ): + initialize_sentry(config) + self.assertTrue(inspect.isclass(odoo.http.Application)) + self.assertIs(odoo.http.root, dummy_root) + self.assertTrue(hasattr(odoo.http.root, "session_store")) + self.assertIs(odoo.http.root.session_store, dummy_root.session_store) + self.assertIsNot(odoo.http.Application.__call__, original_call) + finally: + odoo.http.root = original_root + odoo.http.Application = original_application + + def test_initialize_sentry_wraps_server_app_and_patches_application_call(self): + original_root = odoo.http.root + original_application = odoo.http.Application + + class DummyRoot: + def __init__(self): + self.session_store = object() + + class DummyApplication: + def __call__(self, environ, start_response): + return "ok" + + class DummyServer: + def __init__(self): + self.app = lambda environ, start_response: "server-ok" + + dummy_server = DummyServer() + try: + dummy_root = DummyRoot() + original_call = DummyApplication.__call__ + odoo.http.root = dummy_root + odoo.http.Application = DummyApplication + with ( + patch("odoo.addons.sentry.hooks.server", new=dummy_server), + patch("odoo.addons.sentry.hooks._ORIGINAL_APPLICATION_CALL", new=None), + ): + initialize_sentry(config) + self.assertIsInstance(dummy_server.app, SentryWsgiMiddleware) + self.assertTrue(inspect.isclass(odoo.http.Application)) + self.assertIs(odoo.http.root, dummy_root) + self.assertTrue(hasattr(odoo.http.root, "session_store")) + self.assertIs(odoo.http.root.session_store, dummy_root.session_store) + self.assertIsNot(odoo.http.Application.__call__, original_call) + finally: + odoo.http.root = original_root + odoo.http.Application = original_application From c97fa01fdcddf00b47a1a8fbd4b772efac1c6d7f Mon Sep 17 00:00:00 2001 From: Franco Leyes Date: Fri, 18 Sep 2026 16:58:58 -0300 Subject: [PATCH 2/4] [FIX] base_exception: reload the view after the exception dialog The dialog can confirm the record (ticking "Ignore Exceptions" calls action_confirm on it), but closing it only closes the dialog: the view underneath keeps showing the record as it was before, so the user sees a quotation that is already a sales order. Reload once the dialog closes. --- base_exception/static/src/js/base_exception.esm.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base_exception/static/src/js/base_exception.esm.js b/base_exception/static/src/js/base_exception.esm.js index 3ae4c083176..4abd6f1c681 100644 --- a/base_exception/static/src/js/base_exception.esm.js +++ b/base_exception/static/src/js/base_exception.esm.js @@ -13,7 +13,13 @@ async function popUpException(env, _action) { // Do a soft reload before displaying the popup to display the exception // on the Form view await env.services.action.restore(controller.jsId); - await env.services.action.doAction(popupAction); + await env.services.action.doAction(popupAction, { + onClose: () => + env.services.action.doAction({ + type: "ir.actions.client", + tag: "soft_reload", + }), + }); } function baseExceptionErrorHandler(env, uncaughtError, originalError) { From 6aee67afde70ea9af45b598070b86d61a1ebe503 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 5 Oct 2026 18:28:39 +0000 Subject: [PATCH 3/4] [BOT] post-merge updates --- README.md | 2 +- sentry/README.rst | 2 +- sentry/__manifest__.py | 2 +- sentry/static/description/index.html | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d8998c97ebe..6e647e8a3c6 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ addon | version | maintainers | summary [onchange_helper](onchange_helper/) | 18.0.1.0.1 | | Technical module that ease execution of onchange in Python code [rpc_helper](rpc_helper/) | 18.0.1.0.2 | simahawk | Helpers for disabling RPC calls [scheduler_error_mailer](scheduler_error_mailer/) | 18.0.1.0.0 | | Scheduler Error Mailer -[sentry](sentry/) | 18.0.1.0.4 | barsi naglis versada moylop260 fernandahf | Report Odoo errors to Sentry +[sentry](sentry/) | 18.0.1.0.5 | barsi naglis versada moylop260 fernandahf | Report Odoo errors to Sentry [sequence_python](sequence_python/) | 18.0.1.0.0 | | Calculate a sequence number from a Python expression [session_db](session_db/) | 18.0.1.0.2 | sbidoul | Store sessions in DB [test_auditlog](test_auditlog/) | 18.0.1.0.3 | | Additional unit tests for Audit Log based on accounting models diff --git a/sentry/README.rst b/sentry/README.rst index 70beb0a0412..f1dcf40de50 100644 --- a/sentry/README.rst +++ b/sentry/README.rst @@ -11,7 +11,7 @@ Sentry !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:ef40ec303dcfbdd5896a74fc2e057e8ecbf3301ecef86fbd94821b1cd2e46c8b + !! source digest: sha256:9aff983e27730e612ed4a385dab083e5b8754f73e6e21f9d5d522ccade2593ac !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/sentry/__manifest__.py b/sentry/__manifest__.py index 941bbba7ddc..b7402f40fb7 100644 --- a/sentry/__manifest__.py +++ b/sentry/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Sentry", "summary": "Report Odoo errors to Sentry", - "version": "18.0.1.0.4", + "version": "18.0.1.0.5", "category": "Extra Tools", "website": "https://github.com/OCA/server-tools", "author": "Mohammed Barsi," diff --git a/sentry/static/description/index.html b/sentry/static/description/index.html index 9cc774b37c7..9eac546e567 100644 --- a/sentry/static/description/index.html +++ b/sentry/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Sentry