From fd70d2e34c9e43f33afb22ac1e81a05006bf5ad3 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Sat, 22 Apr 2017 15:03:44 +0200 Subject: [PATCH] [FIX] report_custom_filename: Don't change the initial HTTP response if not OK. (#101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an error occurs into the base class, the response received from the call to super is already an HTTP error response. By modifying this response we break the UI since this reponse is no more the one expeceted in case or error. This change into the initial HTTP reŝponse leeds to different kind of errors into the UI depending of the browser used. (Invalid CSRF error, UI locked in waiting response or 'Blocked a frame with origin http://localhost:8069 from accessing a cross-origin frame' or ...) --- report_custom_filename/controllers/report_controller.py | 3 +++ report_custom_filename/controllers/reports.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/report_custom_filename/controllers/report_controller.py b/report_custom_filename/controllers/report_controller.py index 6d0345147..38e506f87 100644 --- a/report_custom_filename/controllers/report_controller.py +++ b/report_custom_filename/controllers/report_controller.py @@ -41,6 +41,9 @@ class ReportController(ReportController): @http.route(['/report/download']) def report_download(self, data, token): response = super(ReportController, self).report_download(data, token) + if response.status_code != 200: + # In case of error don't change the response. + return response # if we got another content disposition before, ditch the one added # by super() last_index = None diff --git a/report_custom_filename/controllers/reports.py b/report_custom_filename/controllers/reports.py index 77a830f2a..c33b99801 100644 --- a/report_custom_filename/controllers/reports.py +++ b/report_custom_filename/controllers/reports.py @@ -13,6 +13,9 @@ class Reports(main.Reports): @main.serialize_exception def index(self, action, token): result = super(Reports, self).index(action, token) + if result.status_code != 200: + # In case of error don't change the response. + return result action = json.loads(action) context = dict(http.request.context) context.update(action["context"])