From 4a3e934530757542865c2bb13ec7edecb09fc992 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/auditlog/models/http_request.py b/auditlog/models/http_request.py index f2a5f9946..1156925ec 100644 --- a/auditlog/models/http_request.py +++ b/auditlog/models/http_request.py @@ -2,6 +2,8 @@ # © 2015 ABF OSIELL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from psycopg2.extensions import AsIs + from odoo import models, fields, api from odoo.http import request @@ -51,7 +53,14 @@ class AuditlogHTTPRequest(models.Model): 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,