From 0e8e5d4c0a42b3ca3fcd82e70dfbbee795cf261a Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 3 Nov 2022 13:58:32 +0000 Subject: [PATCH] [FIX] web_editor: restore shape on default images in themes Website themes make customizations to the default snippets. In particular, some are applying shapes on default images. To do that, the customization is not applied on the image directly but by changing its src to a special web_editor route in charge of automatically adding the shape on whatever default image the configurator chose for this snippet. Typically, in a snippet with an image whose src is: /web/image/website.my_snippet_default_image The src is replaced by the theme with: /web_editor/image_shape/website.my_snippet_default_image/website/some_shape.svg That controller/route crashed since [1], making those images blank areas in pages generated by the configurator. Indeed, the image from the filestore was accessed via `file_open` which only allows reading inside the addons_paths. [1]: https://github.com/odoo/odoo/commit/da8def8e410de68256ba4ab09ebf7a8b699355ac closes odoo/odoo#105421 X-original-commit: d536e0a23cf0aa06c3ee13fb2c105e83201434e0 Signed-off-by: Quentin Smetz (qsm) Co-authored-by: Julien Castiaux --- addons/web_editor/controllers/main.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index b4e03d97de5..79752d8f70b 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -630,12 +630,7 @@ class Web_Editor(http.Controller): if stream.type == 'url': return stream.get_response() - if stream.type == 'path': - with file_open(stream.path, 'rb') as file: - image = file.read() - else: - image = stream.data - + image = stream.read() img = binary_to_image(image) width, height = tuple(str(size) for size in img.size) root = etree.fromstring(svg)