[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
This commit is contained in:
@@ -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'})
|
||||
|
||||
#------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user