summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2021-01-26 14:11:57 +0000
committerstd-odoo <std@odoo.com>2021-05-26 07:36:03 +0000
commit123dce518a0ea44725c55a0719ea45f6d603ff66 (patch)
treee367d52c07aae36b295bbd6e58d544674478a579 /addons/mail
parentcb996aefb4aeeac9c41359ead523d52c66d21e29 (diff)
[REV] mail: fix a traceback when sending a message in a "email channel"
Bug === Since 4da64b3f3c8dff88d8e0e01c65374590cc0bf4f7 , if multiple users of different companies are in the same channel, and if the type of the channel is "email", a traceback is raised when sending a message. Technical ========= "with_user" drop the SU flag and is not enough to bypass the multi company ACLs. Moreover, we do not want to send a "channel_seen" bus notifications and we can mark the message as seen on the JS side directly. Changes ======= So now, the traceback is not raised anymore in that case, and the message is marked as seen if the receiver has the web client open. But, if the receiver has not the web client open, when he will login, the message will not be marked as seen. This can be improved but at the moment we just want to revert the fix that cause the traceback and fix the issue in most cases. Task 2427790 closes odoo/odoo#65185 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/models/mail_thread.py9
-rw-r--r--addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js4
2 files changed, 5 insertions, 8 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 6e0f725ae41..3064c391a91 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -2176,14 +2176,6 @@ class MailThread(models.AbstractModel):
if channel_ids:
channels = self.env['mail.channel'].sudo().browse(channel_ids)
bus_notifications += channels._channel_message_notifications(message, message_format_values)
- # Message from mailing channel should not make a notification in Odoo for users
- # with notification "Handled by Email", but web client should receive the message.
- # To do so, message is still sent from longpolling, but channel is marked as read
- # in order to remove notification.
- for channel in channels.filtered(lambda c: c.email_send):
- users = channel.channel_partner_ids.mapped('user_ids')
- for user in users.filtered(lambda u: u.notification_type == 'email'):
- channel.with_user(user).channel_seen(message.id)
if bus_notifications:
self.env['bus.bus'].sudo().sendmany(bus_notifications)
@@ -2464,6 +2456,7 @@ class MailThread(models.AbstractModel):
exept_partner = [r['id'] for r in recipient_data['partners']]
if author_id:
exept_partner.append(author_id)
+
sql_query = """ select distinct on (p.id) p.id from res_partner p
left join mail_channel_partner mcp on p.id = mcp.partner_id
left join mail_channel c on c.id = mcp.channel_id
diff --git a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js
index f1ce13bec21..a42ede1c6ae 100644
--- a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js
+++ b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js
@@ -241,6 +241,10 @@ function factory(dependencies) {
channel.mass_mailing &&
this.env.session.notification_type === 'email'
) {
+ this._handleNotificationChannelSeen(channelId, {
+ last_message_id: messageData.id,
+ partner_id: this.env.messaging.currentPartner.id,
+ });
return;
}
// In all other cases: update counter and notify if necessary