Formerly, using sudo() on a record had the effect of replacing the
current user with the superuser. But sometimes, knowing who the "real
user" was was necessary, so we needed to store it somewhere. This is
basically why the key `binary_field_real_user` was introduced in the
context: to keep track of who the user was before switching to sudo
mode.
Since 1e6c3bec2c, however, switching to
sudo mode no longer changes the current user; meaning that the
`binary_field_real_user` is no longer necessary.
This commit removes the remaining occurrences of the now useless
`binary_field_real_user` from the code.
* = hr, portal, web_editor
closesodoo/odoo#92032
Enterprise: https://github.com/odoo/enterprise/pull/27649
Related: odoo/enterprise#27649
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
Reading only 'id' with `search_read` is equivalent to use `search` but
complexify the result usage. Fix all these bad usages.
Part-of: odoo/odoo#104838
Co-authored-by: Julien Castiaux <juc@odoo.com>
* website_forum
Portal users cannot insert images in the WYSIWYG, eg in a forum post.
Steps to reproduce:
- Install website_forum
- Connect as portal
- Go to the forum and create a new post
- Type '/image' and try to insert an image
- An Access Error is raised preventing the portal user from inserting an
image
History:
- It was possible in version earlier than 15.0 before the new editor, as
it was using a base64 inplace image upload to bypass the access rights
and avoid creating an attachment.
- It was broken in 15.0 with the new editor which doesn't have such a
mechanism. The image upload was then disabled for those users in 15.0
with [1] to avoid that bad UX with those errors/tracebacks.
- It was decided to implement a clean solution in master and see from
there was will be done with 15.0 (as being able to upload an image on
a forum seems quite critical).
Solution here in master to be able to use the media dialog:
- First issue, about opening the media dialog:
It fetches attachments, which is raising some access errors. We now
catch the error silently and return an empty list.
- Second issue, about upload an image (and thus creating an attachment):
We now create attachments with sudo to allow access to portal users,
but only if he has write access on the model.
[1]: https://github.com/odoo/odoo/commit/e453d4c119a69f285d9a014babe485492bbe9c40
opw-2648770
task-2811325
closesodoo/odoo#82612
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Co-authored-by: Merlin (megu) <megu@odoo.com>
Since [1] the attachments are not found by `get_image_info` anymore
because the search based on the id only does not specify the model.
Because of this the mimetype of uploaded images is not put in the DOM
image's dataset. This lack of mimetype prevents the Shape, Filter, Width
and Quality image options from being used.
This commit defaults the model to `ir.attachment`.
Steps to reproduce:
- Drop a "Text - Image" snippet.
- Replace the image by uploading one.
=> The Shape, Filter, Width & Quality options did not appear anymore.
[1]: https://github.com/odoo/odoo/commit/da8def8e410de68256ba4ab09ebf7a8b699355ac
task-2883695
closesodoo/odoo#94288
X-original-commit: 99fda1024ff7d809f13523acd13770c02a49d1e1
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Since [1] illustration shapes are only obtained from their slug. Before
they were obtained from their URL.
After this commit the old behavior is restored as a fallback in case the
illustration shape cannot be found from its slug.
This is needed to allow importing shapes into the system from data
files.
[1]: https://github.com/odoo/odoo/commit/bde8abcfeb57c74438943e44215a7c8cb822329f
task-2793073
closesodoo/odoo#86858
X-original-commit: 91f2a989ddd7961f92a377b1bf74cc741dcbd3d0
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Since [1] non-image documents uploaded in web editor were stored as
received in base64 without being decoded.
This led to downloading them as they were stored in base64.
After this commit uploaded documents are base64-decoded before being
stored.
Steps to reproduce:
- edit a web page
- drop a "Text - Image" snippet
- replace the image
- upload a document (PDF, TXT...)
- save page
- download document
=> received document was base64-encoded
[1]: https://github.com/odoo/odoo/commit/6b8752604898bf2b583b7f5334e35f6a1583595e
task-2782269
closesodoo/odoo#86812
X-original-commit: b0218b8ff50c7cea2a018d20a62e63510bfdd01e
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>