From 29d5134d3c640ef14b0fbe2b905cb9a820293c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 24 Sep 2019 16:01:12 +0000 Subject: [PATCH] [FIX] mass_mailing_sms: fix sms mailing retry not really working Retry was not working for SMS marketing as it was actually not really implemented. It now correctly unlinks failed sms and traces and reschedule the mailing accordingly It is also possible now to force send while being in queue mode to avoid having to switch too much between states. LINKS Task 2076366 (send now) Task 2067873 (template access) PR #37298 PR odoo/enterprise#5750 --- addons/mass_mailing_sms/models/mailing_mailing.py | 15 +++++++++++++++ .../views/mailing_mailing_views.xml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing_sms/models/mailing_mailing.py b/addons/mass_mailing_sms/models/mailing_mailing.py index 9200bf8618a..b71cf3cc274 100644 --- a/addons/mass_mailing_sms/models/mailing_mailing.py +++ b/addons/mass_mailing_sms/models/mailing_mailing.py @@ -75,6 +75,21 @@ class Mailing(models.Model): self.write({'sms_force_send': True}) return self.action_send_mail() + def action_retry_failed(self): + mass_sms = self.filtered(lambda m: m.mailing_type == 'sms') + if mass_sms: + mass_sms.action_retry_failed_sms() + return super(Mailing, self - mass_sms).action_retry_failed() + + def action_retry_failed_sms(self): + failed_sms = self.env['sms.sms'].sudo().search([ + ('mailing_id', 'in', self.ids), + ('state', '=', 'error') + ]) + failed_sms.mapped('mailing_trace_ids').unlink() + failed_sms.unlink() + self.write({'state': 'in_queue'}) + def action_test(self): if self.mailing_type == 'sms': ctx = dict(self.env.context, default_mailing_id=self.id) diff --git a/addons/mass_mailing_sms/views/mailing_mailing_views.xml b/addons/mass_mailing_sms/views/mailing_mailing_views.xml index 2c774bd9e9c..b0fb2c129b9 100644 --- a/addons/mass_mailing_sms/views/mailing_mailing_views.xml +++ b/addons/mass_mailing_sms/views/mailing_mailing_views.xml @@ -29,7 +29,7 @@ confirm="This will schedule an SMS marketing to all recipients. Do you still want to proceed ?"/>