diff --git a/addons/stock/controllers/main.py b/addons/stock/controllers/main.py index f508ba19ffd..805b9378428 100644 --- a/addons/stock/controllers/main.py +++ b/addons/stock/controllers/main.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- +import werkzeug +from werkzeug.exceptions import InternalServerError from odoo import http from odoo.http import request -from odoo.tools import html_escape import json @@ -32,4 +33,9 @@ class StockReportController(http.Controller): 'message': 'Odoo Server Error', 'data': se } - return request.make_response(html_escape(json.dumps(error))) + res = werkzeug.wrappers.Response( + json.dumps(error), + status=500, + headers=[("Content-Type", "application/json")] + ) + raise InternalServerError(response=res) from e diff --git a/addons/web/controllers/report.py b/addons/web/controllers/report.py index 8ba955f378d..e7001a11c9d 100644 --- a/addons/web/controllers/report.py +++ b/addons/web/controllers/report.py @@ -12,7 +12,6 @@ from werkzeug.urls import url_parse from odoo import http from odoo.http import content_disposition, request -from odoo.tools import html_escape from odoo.tools.safe_eval import safe_eval, time @@ -144,7 +143,12 @@ class ReportController(http.Controller): 'message': "Odoo Server Error", 'data': se } - return request.make_response(html_escape(json.dumps(error))) + res = werkzeug.wrappers.Response( + json.dumps(error), + status=500, + headers=[("Content-Type", "application/json")] + ) + raise werkzeug.exceptions.InternalServerError(response=res) from e @http.route(['/report/check_wkhtmltopdf'], type='json', auth="user") def check_wkhtmltopdf(self):