Skip to content
Browse files

simplify notifications

  • Loading branch information...
Xavier-Do committed Apr 12, 2019
1 parent c806568 commit dbefc76612f0f3a256efed5e57fd59ec488bcb82
Showing with 5 additions and 10 deletions.
  1. +5 −10 addons/mail/models/
@@ -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[''].sudo().browse(channel_ids)._channel_message_notifications(message, message_values)
notifications += self.env[''].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:
if channel_ids:
# send a notification on bus to update channel
if 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 dbefc76

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