From bc05c3c9b57396edf4877f991d5819009f251894 Mon Sep 17 00:00:00 2001 From: sebalix Date: Fri, 30 Oct 2015 18:17:05 +0100 Subject: [PATCH] Module 'auditlog' - A log can be created with no current HTTP request (unit tests, ir.cron...) --- auditlog/models/http_request.py | 2 ++ auditlog/models/http_session.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/auditlog/models/http_request.py b/auditlog/models/http_request.py index 357c1a7d4..77f9aa09f 100644 --- a/auditlog/models/http_request.py +++ b/auditlog/models/http_request.py @@ -46,6 +46,8 @@ class AuditlogHTTPRequest(models.Model): first call. If no HTTP request is available, returns `False`. """ + if not request: + return False http_session_model = self.env['auditlog.http.session'] httprequest = request.httprequest if httprequest: diff --git a/auditlog/models/http_session.py b/auditlog/models/http_session.py index deb2ee27c..2bbf736e6 100644 --- a/auditlog/models/http_session.py +++ b/auditlog/models/http_session.py @@ -42,6 +42,8 @@ class AuditlogtHTTPSession(models.Model): first call. If no HTTP user session is available, returns `False`. """ + if not request: + return False httpsession = request.httpsession if httpsession: existing_session = self.search(