diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index bab78cd4b07..a573849dd02 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -842,17 +842,8 @@ class Message(models.Model): # update message self.write({'channel_ids': [(6, 0, channels.ids)], 'needaction_partner_ids': [(6, 0, partners.ids)]}) - # notify partners - # TDE TODO: model-dependant ? (like customer -> always email ?) - email_channels = channels.filtered(lambda channel: channel.email_send) - self.env['res.partner'].sudo().search([ - '|', - ('id', 'in', partners.ids), - ('channel_ids', 'in', email_channels.ids), - ('email', '!=', self_sudo.author_id and self_sudo.author_id.email or self.email_from), - ('notify_email', '!=', 'none')] - )._notify(self, force_send=force_send, user_signature=user_signature) # notify partners and channels + partners._notify(self, force_send=force_send, user_signature=user_signature) channels._notify(self) # Discard cache, because child / parent allow reading and therefore diff --git a/addons/mail/models/res_partner.py b/addons/mail/models/res_partner.py index 3407f1c8460..928140ba526 100644 --- a/addons/mail/models/res_partner.py +++ b/addons/mail/models/res_partner.py @@ -115,6 +115,19 @@ class Partner(models.Model): @api.multi def _notify(self, message, force_send=False, user_signature=True): + # TDE TODO: model-dependant ? (like customer -> always email ?) + message_sudo = message.sudo() + email_channels = message.channel_ids.filtered(lambda channel: channel.email_send) + self.sudo().search([ + '|', + ('id', 'in', self.ids), + ('channel_ids', 'in', email_channels.ids), + ('email', '!=', message_sudo.author_id and message_sudo.author_id.email or message.email_from), + ('notify_email', '!=', 'none')])._notify_by_email(message, force_send=force_send, user_signature=user_signature) + return True + + @api.multi + def _notify_by_email(self, message, force_send=False, user_signature=True): """ Method to send email linked to notified messages. The recipients are the recordset on which this method is called. """ if not self.ids: