Browse Source

[FIX] Request id no longer exists after concurrency rollback

pull/1040/head
Stefan Rijnhart 8 years ago
committed by Enric Tobella
parent
commit
ffef2bdc3c
No known key found for this signature in database GPG Key ID: 1A2546A1B7BA2451
  1. 9
      auditlog/models/http_request.py

9
auditlog/models/http_request.py

@ -2,6 +2,8 @@
# © 2015 ABF OSIELL <http://osiell.com> # © 2015 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # 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 import models, fields, api
from odoo.http import request from odoo.http import request
@ -51,6 +53,13 @@ class AuditlogHTTPRequest(models.Model):
httprequest = request.httprequest httprequest = request.httprequest
if httprequest: if httprequest:
if hasattr(httprequest, 'auditlog_http_request_id'): if hasattr(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 return httprequest.auditlog_http_request_id
vals = { vals = {
'name': httprequest.path, 'name': httprequest.path,

Loading…
Cancel
Save