Skip to content
Permalink
Browse files

simplify notifications

  • Loading branch information...
Xavier-Do committed Apr 12, 2019
1 parent 510ee65 commit 41e6e15200969927d167f1851e2c23d3231951c3
Showing with 5 additions and 10 deletions.
  1. +5 −10 addons/mail/models/mail_thread.py
@@ -2213,25 +2213,20 @@ def _notify_record(self, message, msg_vals, model_description=False, mail_auto_d
partner_email_rdata = [r for r in rdata['partners'] if r['notif'] == 'email']
channel_ids = [r['id'] for r in rdata['channels']]

#25 queries only for message format while we basicaly have all data available
notifications = []
if inbox_pids or channel_ids:
message_values = False
if inbox_pids:
message_values = message.message_format()[0] # 26 queries computing message format once, 10 less queries
partner_notifications = []
for partner in inbox_pids:
partner_notifications.append([(self._cr.dbname, 'ir.needaction', partner), dict(message_values)])
notifications.append([(self._cr.dbname, 'ir.needaction', partner), dict(message_values)])
if channel_ids:
channel_notifications = self.env['mail.channel'].sudo().browse(channel_ids)._channel_message_notifications(message, message_values)
notifications += self.env['mail.channel'].sudo().browse(channel_ids)._channel_message_notifications(message, message_values)
if partner_email_rdata:
# classify recipients: actions / no action
# 70 queries
self._notify_partners(message, partner_email_rdata, msg_vals=msg_vals, model_description=model_description, mail_auto_delete=mail_auto_delete)
if inbox_pids:
self.env['bus.bus'].sudo().sendmany(partner_notifications)
if channel_ids:
# send a notification on bus to update channel
self.env['bus.bus'].sudo().sendmany(channel_notifications)
if notifications:
self.env['bus.bus'].sudo().sendmany(notifications)
return True

def _notify_partners(self, message, partners_data, msg_vals=False, model_description=False, mail_auto_delete=True, send_after_commit=False):

0 comments on commit 41e6e15

Please sign in to comment.
You can’t perform that action at this time.