From 5bd895721af41306bbaca2103a8ca7d061c122fa Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 2 Feb 2017 09:18:16 +0100 Subject: [PATCH] [IMP] base: new cr for log method The `log` method of a server action uses the same cursor than the transaction. Therefore, if an error is raised during the server action execution, the log messages are lost since the transaction is rolled back. We introduce a new cursor in the `log` method, so the log messages are kept even when an exception is raised. opw-704036 --- odoo/addons/base/ir/ir_actions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/odoo/addons/base/ir/ir_actions.py b/odoo/addons/base/ir/ir_actions.py index 000f39f1442..993548e9c64 100644 --- a/odoo/addons/base/ir/ir_actions.py +++ b/odoo/addons/base/ir/ir_actions.py @@ -896,10 +896,11 @@ class IrActionsServer(models.Model): :type action: browse record :returns: dict -- evaluation context given to (safe_)safe_eval """ def log(message, level="info"): - self._cr.execute(""" - INSERT INTO ir_logging(create_date, create_uid, type, dbname, name, level, message, path, line, func) - VALUES (NOW() at time zone 'UTC', %s, %s, %s, %s, %s, %s, %s, %s, %s) - """, (self.env.uid, 'server', self._cr.dbname, __name__, level, message, "action", action.id, action.name)) + with self.pool.cursor() as cr: + cr.execute(""" + INSERT INTO ir_logging(create_date, create_uid, type, dbname, name, level, message, path, line, func) + VALUES (NOW() at time zone 'UTC', %s, %s, %s, %s, %s, %s, %s, %s, %s) + """, (self.env.uid, 'server', self._cr.dbname, __name__, level, message, "action", action.id, action.name)) eval_context = super(IrActionsServer, self)._get_eval_context(action=action) model = self.env[action.model_id.model]