[FIX] *: replace werkzeug's Response by odoo's Response
*: base, http_routing, mass_mailing, web, web_editor, website_slides In some situations `werkzeug.wrappers.Response` are used instead of `odoo.http.Reponse` that extends it. This is a problem because since [1] the calls to `set_cookie` expect it to accept the `cookie_type` parameter, which is not the case in the base werkzeug implementation. This commit replaces the `werkzeug.wrappers.Response` by `odoo.http.Response`. [1]: https://github.com/odoo/odoo/commit/2cbda6c98ee947cea1d06c09880eee8c758304a8 closes odoo/odoo#112827 X-original-commit: 28da08292b7028575e628c5ad846fc05d30498f2 Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import odoo
|
||||
import odoo.modules.registry
|
||||
from odoo import http, _
|
||||
from odoo.exceptions import AccessError, UserError
|
||||
from odoo.http import request
|
||||
from odoo.http import request, Response
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo.tools import file_open, file_path, replace_exceptions
|
||||
from odoo.tools.mimetypes import guess_mimetype
|
||||
@@ -241,8 +241,14 @@ class Binary(http.Controller):
|
||||
imgext = '.' + mimetype.split('/')[1]
|
||||
if imgext == '.svg+xml':
|
||||
imgext = '.svg'
|
||||
response = send_file(image_data, request.httprequest.environ,
|
||||
download_name=imgname + imgext, mimetype=mimetype, last_modified=row[1])
|
||||
response = send_file(
|
||||
image_data,
|
||||
request.httprequest.environ,
|
||||
download_name=imgname + imgext,
|
||||
mimetype=mimetype,
|
||||
last_modified=row[1],
|
||||
response_class=Response,
|
||||
)
|
||||
else:
|
||||
response = http.Stream.from_path(placeholder('nologo.png')).get_response()
|
||||
except Exception:
|
||||
|
||||
@@ -6,17 +6,12 @@ import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
import werkzeug
|
||||
import werkzeug.exceptions
|
||||
import werkzeug.utils
|
||||
import werkzeug.wrappers
|
||||
import werkzeug.wsgi
|
||||
from lxml import html
|
||||
|
||||
import odoo
|
||||
import odoo.modules.registry
|
||||
from odoo import http
|
||||
from odoo.http import content_disposition, dispatch_rpc, request
|
||||
from odoo.http import content_disposition, dispatch_rpc, request, Response
|
||||
from odoo.service import db
|
||||
from odoo.tools.misc import file_open, str2bool
|
||||
from odoo.tools.translate import _
|
||||
@@ -138,7 +133,7 @@ class Database(http.Controller):
|
||||
('Content-Disposition', content_disposition(filename)),
|
||||
]
|
||||
dump_stream = odoo.service.db.dump_db(name, None, backup_format)
|
||||
response = werkzeug.wrappers.Response(dump_stream, headers=headers, direct_passthrough=True)
|
||||
response = Response(dump_stream, headers=headers, direct_passthrough=True)
|
||||
return response
|
||||
except Exception as e:
|
||||
_logger.exception('Database.backup')
|
||||
|
||||
@@ -3,11 +3,7 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
import werkzeug
|
||||
import werkzeug.exceptions
|
||||
import werkzeug.utils
|
||||
import werkzeug.wrappers
|
||||
import werkzeug.wsgi
|
||||
from werkzeug.urls import url_parse
|
||||
|
||||
from odoo import http
|
||||
|
||||
Reference in New Issue
Block a user