[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) <xmo@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Tom De Caluwé
2022-04-21 11:33:56 +02:00
parent ed2c2a234e
commit 7b1ffd6315
+3 -2
View File
@@ -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'):