Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] fs_file: Browse attachment with sudo to avoid read access errors #288

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.