Skip to content

Commit

Permalink
[FIX] mail: odoobot message remains unread
Browse files Browse the repository at this point in the history
Before this commit, messages sent by OdooBot would remain unread.
1. Log in as demo user
2. Open OdooBot chat, remains unread

This happens because the `_set_last_seen_message` method called by the
OdooBot reply logic sets the message as seen for the user. This results
in the message being marked as read before it is received, preventing
it to be marked as read by the client.
This commit fixes the issue by preventing the message to be mark as
read if the author is not the current user.

Also added missing `message_unread_counter_bus_id` from
`assignedDefined` that would prevent it to be set by record inserts.

task-4295630
opw-4316799

closes odoo#188523

X-original-commit: abcc17c
Signed-off-by: Alexandre Kühn (aku) <[email protected]>
  • Loading branch information
Atovange authored and alexkuhn committed Nov 26, 2024
1 parent 1f44390 commit 8acfad7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/mail/models/discuss/discuss_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,9 @@ def _message_post_after_hook(self, message, msg_vals):
"""
Automatically set the message posted by the current user as seen for themselves.
"""
if current_channel_member := self.env["discuss.channel.member"].search([
if (current_channel_member := self.env["discuss.channel.member"].search([
("channel_id", "=", self.id), ("is_self", "=", True)
]):
])) and message.is_current_user_or_guest_author:
current_channel_member._set_last_seen_message(message, notify=False)
current_channel_member._set_new_message_separator(message.id + 1, sync=True)
return super()._message_post_after_hook(message, msg_vals)
Expand Down
3 changes: 3 additions & 0 deletions addons/test_discuss_full/tests/test_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ def setUp(self):
author_id=self.users[2].partner_id.id,
partner_ids=self.users[0].partner_id.ids,
)
members = self.channel_channel_public_1.channel_member_ids
member = members.filtered(lambda m: m.partner_id == self.users[0].partner_id).with_user(self.users[0])
member._mark_as_read(message_0.id)
# add star
message_0.toggle_message_starred()
self.env.company.sudo().name = 'YourCompany'
Expand Down

0 comments on commit 8acfad7

Please sign in to comment.