[IMP] base: make sure binary_field_real_user is a record

Ensure that the value of binary_field_real_user is a record before using
it.

closes odoo/odoo#92441

X-original-commit: 4ccf918c1596ac0ee104774d98d014708f03e901
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Louis Wicket (wil)
2022-05-30 15:32:13 +02:00
parent 309be771a5
commit da11c4cdf4
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -28591,6 +28591,12 @@ msgstr ""
msgid "binary"
msgstr ""
#. module: base
#: code:addons/base/models/ir_attachment.py:0
#, python-format
msgid "binary_field_real_user should be a res.users record."
msgstr ""
#. module: base
#: model:ir.model.fields.selection,name:base.selection__ir_model_fields__ttype__boolean
msgid "boolean"
+2
View File
@@ -341,6 +341,8 @@ 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)
if not isinstance(user, self.pool['res.users']):
raise UserError(_("binary_field_real_user should be a res.users record."))
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))