From 99974027a2bb82fe761ab09950e55c86d694ad9e Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 4 Jul 2016 15:47:08 +0200 Subject: [PATCH] [FIX] singleton error if we saved the current session two times (#473) * [IMP] index the columns we'll be searching for for every request * [FIX] singleton error if we saved the current session two times --- auditlog/models/http_session.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auditlog/models/http_session.py b/auditlog/models/http_session.py index 183cb6396..872290afb 100644 --- a/auditlog/models/http_session.py +++ b/auditlog/models/http_session.py @@ -13,9 +13,9 @@ class AuditlogtHTTPSession(models.Model): _rec_name = 'display_name' display_name = fields.Char(u"Name", compute="_display_name") - name = fields.Char(u"Session ID") + name = fields.Char(u"Session ID", index=True) user_id = fields.Many2one( - 'res.users', string=u"User") + 'res.users', string=u"User", index=True) http_request_ids = fields.One2many( 'auditlog.http.request', 'http_session_id', string=u"HTTP Requests") @@ -43,7 +43,8 @@ class AuditlogtHTTPSession(models.Model): if httpsession: existing_session = self.search( [('name', '=', httpsession.sid), - ('user_id', '=', request.uid)]) + ('user_id', '=', request.uid)], + limit=1) if existing_session: return existing_session.id vals = {