From 4504656f3f37b8730deabfcfae0b8436351f9fa9 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 16 Jan 2017 12:44:14 +0100 Subject: [PATCH] [FIX] Request id no longer exists after concurrency rollback --- auditlog/models/http_request.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/auditlog/models/http_request.py b/auditlog/models/http_request.py index ca896ea9940..9d8e9123718 100644 --- a/auditlog/models/http_request.py +++ b/auditlog/models/http_request.py @@ -2,6 +2,7 @@ # © 2015 ABF OSIELL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from psycopg2.extensions import AsIs from openerp import models, fields, api from openerp.http import request @@ -47,7 +48,14 @@ def current_http_request(self): httprequest = request.httprequest if httprequest: if hasattr(httprequest, 'auditlog_http_request_id'): - return httprequest.auditlog_http_request_id + # Verify existence. Could have been rolled back after a + # concurrency error + self.env.cr.execute( + "SELECT id FROM %s WHERE id = %s", ( + AsIs(self._table), + httprequest.auditlog_http_request_id)) + if self.env.cr.fetchone(): + return httprequest.auditlog_http_request_id vals = { 'name': httprequest.path, 'root_url': httprequest.url_root,