From a9fa46fdc8b98c44a8b0966b94ae623ec3ff66ba Mon Sep 17 00:00:00 2001 From: Hugo Adan Date: Sat, 12 Jan 2019 01:16:45 +0000 Subject: [PATCH] [FIX] mass_mailing: make retry failed mail work with keep archive set to False Let M be a mass_mailing. For all messages m related to M, retry_failed_mail removes the mail statistics of m before putting M 'in_queue'. Since there are no statistics on m, its recipient is returned by the function get_remaining_recipients when called by send_mail once M is processed. However when keep archive is set to False, the 'mail.mail' records are automatically removed. As a results their statistics are not removed, and thus these mails are not retried. closes odoo/odoo#30158 --- addons/mass_mailing/models/mass_mailing.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index f4753f9bd07..3c1fa6dcc46 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -558,6 +558,12 @@ class MassMailing(models.Model): failed_mails = self.env['mail.mail'].search([('mailing_id', 'in', self.ids), ('state', '=', 'exception')]) failed_mails.mapped('statistics_ids').unlink() failed_mails.sudo().unlink() + res_ids = self.get_recipients() + except_mailed = self.env['mail.mail.statistics'].search([ + ('model', '=', self.mailing_model_real), + ('res_id', 'in', res_ids), + ('exception', '!=', False), + ('mass_mailing_id', '=', self.id)]).unlink() self.write({'state': 'in_queue'}) #------------------------------------------------------