[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
This commit is contained in:
Thibault Delavallée
2019-09-25 11:13:03 +00:00
parent 48cc126137
commit 29d5134d3c
2 changed files with 16 additions and 1 deletions
@@ -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)
@@ -29,7 +29,7 @@
confirm="This will schedule an SMS marketing to all recipients. Do you still want to proceed ?"/>
<button name="action_send_now_sms" type="object"
string="Send Now"
attrs="{'invisible': ['|', ('mailing_type', '=', 'mail'), ('state', 'in', ('in_queue', 'done'))]}"
attrs="{'invisible': ['|', ('mailing_type', '=', 'mail'), ('state', 'in', ('done'))]}"
confirm="This will send SMS to all recipients now. Do you still want to proceed ?"/>
</xpath>
<!-- Headers / Warnings -->