From 4778cd384190f3dabbd565beb88c635cb940d954 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 6 Apr 2026 14:15:52 +0700 Subject: [PATCH] debug: add monkey-patch to UserError to trace expense report locking errors and remove unused controllers import --- __init__.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index f7209b1..72d24ea 100644 --- a/__init__.py +++ b/__init__.py @@ -1,2 +1,22 @@ +import logging +import traceback +from odoo.exceptions import UserError + +_logger = logging.getLogger(__name__) + +# Diagnostic monkey-patch to find where the UserError is coming from +original_init = UserError.__init__ + +def diagnostic_init(self, *args, **kwargs): + message = args[0] if args else "" + if "linked to an expense report" in str(message): + with open("/tmp/odoo_lock_traceback.txt", "w") as f: + f.write("LOCKED ERROR CAUGHT!\n") + f.write(f"Message: {message}\n") + f.write("TRACEBACK:\n") + traceback.print_stack(file=f) + return original_init(self, *args, **kwargs) + +UserError.__init__ = diagnostic_init + from . import models -from . import controllers