Skip to content

Commit b36da25

Browse files
hbrunnlembregtse
authored andcommitted
singleton error if we saved the current session two times (OCA#473)
* [IMP] index the columns we'll be searching for for every request * [FIX] singleton error if we saved the current session two times
1 parent a965b26 commit b36da25

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

auditlog/models/http_session.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class AuditlogtHTTPSession(models.Model):
1313
_rec_name = 'display_name'
1414

1515
display_name = fields.Char(u"Name", compute="_display_name")
16-
name = fields.Char(u"Session ID")
16+
name = fields.Char(u"Session ID", index=True)
1717
user_id = fields.Many2one(
18-
'res.users', string=u"User")
18+
'res.users', string=u"User", index=True)
1919
http_request_ids = fields.One2many(
2020
'auditlog.http.request', 'http_session_id', string=u"HTTP Requests")
2121

@@ -43,7 +43,8 @@ def current_http_session(self):
4343
if httpsession:
4444
existing_session = self.search(
4545
[('name', '=', httpsession.sid),
46-
('user_id', '=', request.uid)])
46+
('user_id', '=', request.uid)],
47+
limit=1)
4748
if existing_session:
4849
return existing_session.id
4950
vals = {

0 commit comments

Comments
 (0)