Skip to content

Commit

Permalink
[FIX] Request id no longer exists after concurrency rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Feb 21, 2017
1 parent 6047e95 commit 4a3e934
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion auditlog/models/http_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# © 2015 ABF OSIELL <http://osiell.com>
# 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

Expand Down Expand Up @@ -51,7 +53,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,
Expand Down

0 comments on commit 4a3e934

Please sign in to comment.