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