Skip to content

Commit

Permalink
[FIX] fs_file: Browse attachment with sudo to avoid read access errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Oct 16, 2023
1 parent 2ca222b commit ec8a63d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fs_file/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def convert_to_cache(self, value, record, validate=True):
# we come from an onchange
# The id is the third element of the url
att_id = value["url"].split("/")[3]
attachment = record.env["ir.attachment"].browse(int(att_id))
attachment = record.env["ir.attachment"].sudo().browse(int(att_id))
return self._convert_attachment_to_cache(attachment)
return FSFileValue(
name=value["filename"], value=base64.b64decode(value["content"])
Expand Down
6 changes: 6 additions & 0 deletions fs_file/readme/newsfragments/288.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Browse attachment with sudo() to avoid read access errors

In models that have a multi fs image relation, a new line
in form will trigger onchanges and will call the fs.file model
'convert_to_cache()' method that will try to browse the attachment
with user profile that could have no read rights on attachment model.

0 comments on commit ec8a63d

Please sign in to comment.