From 7b1ffd631590d33b693b568a398a22b13649e7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20De=20Caluw=C3=A9?= Date: Thu, 31 Mar 2022 12:25:36 +0000 Subject: [PATCH] [FIX] website, base: allow modify_image calls on svg for designers SVG images are considered an xml like format, as a consequence restrictions apply for manipulating svg type attachments. This poses a problem when a website designer tries to save a page containing images with svg shapes. This commit allows writing attachments with an xml like mimetype to anyone with write access rights on views. opw-2806930 closes odoo/odoo#89185 X-original-commit: d5aa54ca108eb99c7eb855a7d456bfe2f208a8eb Signed-off-by: Xavier Morel (xmo) Signed-off-by: Quentin Smetz (qsm) --- odoo/addons/base/models/ir_attachment.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/odoo/addons/base/models/ir_attachment.py b/odoo/addons/base/models/ir_attachment.py index a05392d8ded..c9bae38e7ef 100644 --- a/odoo/addons/base/models/ir_attachment.py +++ b/odoo/addons/base/models/ir_attachment.py @@ -341,8 +341,9 @@ class IrAttachment(models.Model): 'xml' in mimetype and # other xml (svg, text/xml, etc) not 'openxmlformats' in mimetype) # exception for Office formats user = self.env.context.get('binary_field_real_user', self.env.user) - force_text = (xml_like and (not user._is_system() or - self.env.context.get('attachments_mime_plainxml'))) + force_text = xml_like and ( + self.env.context.get('attachments_mime_plainxml') or + not self.env['ir.ui.view'].with_user(user).check_access_rights('write', False)) if force_text: values['mimetype'] = 'text/plain' if not self.env.context.get('image_no_postprocess'):