From 6ddcb448612f5d784c8e9ebb90f19077e65be3e1 Mon Sep 17 00:00:00 2001 From: "Achraf (abz)" Date: Thu, 4 May 2023 13:26:36 +0000 Subject: [PATCH] [FIX] base: Update non-stored field error logging to include exc details We have many issues with this log, except that with a `logger.error` we do not have exception information (exc_info). As mentionned in the documentation above, we cannot use `logger.exception` in this case because we are not within an exception handler. However, we can still retrieve the exception information using `sys` module and the `exc_info()` method. https://docs.python.org/3/library/logging.html#logging.Logger.exception ``` exception(msg, *args, **kwargs) ... This method should only be called from an exception handler. ``` https://docs.python.org/3/library/sys.html#sys.exc_info ``` sys.exc_info() This function returns the old-style representation of the handled exception. ... If no exception is being handled anywhere on the stack, this function return a tuple containing three None values. ... ``` closes odoo/odoo#124208 X-original-commit: b0844d2f3c0c9655746b4c16c9b612bae9954618 Signed-off-by: Christophe Simonis (chs) --- odoo/osv/expression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/osv/expression.py b/odoo/osv/expression.py index 80578027dfa..28f51a1a6eb 100644 --- a/odoo/osv/expression.py +++ b/odoo/osv/expression.py @@ -1105,7 +1105,7 @@ class expression(object): # Non-stored field should provide an implementation of search. if not field.search: # field does not support search! - _logger.error("Non-stored field %s cannot be searched.", field) + _logger.error("Non-stored field %s cannot be searched.", field, exc_info=True) if _logger.isEnabledFor(logging.DEBUG): _logger.debug(''.join(traceback.format_stack())) # Ignore it: generate a dummy leaf.