Skip to content

Commit

Permalink
[FIX] mail: fix access rights for reaction in portal
Browse files Browse the repository at this point in the history
Before this commit, the portal user get a Access Error.
After this commit, the portal user see the chatter without error.

The code works with reaction browsed in sudo, but since we use a ior
with a record not in sudo, we loose the sudo flag and so the right for
portal user to read it.

```py
x = record.sudo()
y = record
x |= y -> (x, y) in sudo
y |= x -> (x, y) not in sudo
```

How to reproduce ?
Assign lead to a portal user
Post a message with another user like demo on the lead
Add reaction with the admin user
Open the opportunity on the portal with portal user
-> access error

opw-3215507

closes odoo#117313

X-original-commit: 2bde535
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Jérémy Kersten <jke@odoo.com>
  • Loading branch information
JKE-be committed Mar 31, 2023
1 parent a31ad57 commit 5188471
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/mail/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def _message_format(self, fnames, format_reply=True, legacy=False):
else:
record_name = False
default_subject = False
reactions_per_content = defaultdict(lambda: self.env['mail.message.reaction'])
reactions_per_content = defaultdict(self.env['mail.message.reaction'].sudo().browse)
for reaction in message_sudo.reaction_ids:
reactions_per_content[reaction.content] |= reaction
reaction_groups = [{
Expand Down

0 comments on commit 5188471

Please sign in to comment.