summaryrefslogtreecommitdiff
path: root/addons/mass_mailing_sms/models/mailing_mailing.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-09-24 13:03:45 +0000
committerThibault Delavallée <tde@odoo.com>2019-09-25 11:12:59 +0000
commit48cc126137bb1abead26ca68ba8376cbd2cfe120 (patch)
treee0001647297774d0cd183e907ff3db0a1683582d /addons/mass_mailing_sms/models/mailing_mailing.py
parent889d30e2c80a561b41298a8fab52478c48b2c687 (diff)
[FIX] (mass_mailing_)sms: allow to directly send SMS in mass mode
PURPOSE Sending SMS is sometimes required as an immediate marketing tool. Using delayed crons is not always the best user choice. Implement a Send Now mechanism in batch SMS. SPECIFICATIONS Allow to send directly SMS when doing SMS marketing SMS Application * in sms composer, in mass mode: rename Send SMS to Put in queue and add a Send Now button by-passing the queue; * set Put in queue as primary, Send Now as secondary; SMS Marketing Application * in mailing view for SMS: rename Send SMS to Put in queue and add a Send Now button by-passing the queue; * set Put in queue as primary, Send Now as secondary; Tests of SMS marketing with 400 contacts to SMS indicates it takes about 10 seconds to be completed which is considered as ok. LINKS Task 2076366 (send now) Task 2067873 (template access) PR #37298 PR odoo/enterprise#5750
Diffstat (limited to 'addons/mass_mailing_sms/models/mailing_mailing.py')
-rw-r--r--addons/mass_mailing_sms/models/mailing_mailing.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/addons/mass_mailing_sms/models/mailing_mailing.py b/addons/mass_mailing_sms/models/mailing_mailing.py
index 49d7b6a0a3c..9200bf8618a 100644
--- a/addons/mass_mailing_sms/models/mailing_mailing.py
+++ b/addons/mass_mailing_sms/models/mailing_mailing.py
@@ -20,6 +20,8 @@ class Mailing(models.Model):
sms_has_insufficient_credit = fields.Boolean(
'Insufficient IAP credits', compute='_compute_sms_has_insufficient_credit',
help='UX Field to propose to buy IAP credits')
+ sms_force_send = fields.Boolean(
+ 'Send Directly', help='Use at your own risks.')
# opt_out_link
sms_allow_unsubscribe = fields.Boolean('Include opt-out link', default=True)
@@ -63,7 +65,15 @@ class Mailing(models.Model):
# --------------------------------------------------
def action_put_in_queue_sms(self):
- return self.action_put_in_queue()
+ res = self.action_put_in_queue()
+ if self.sms_force_send:
+ self.action_send_mail()
+ return res
+
+ def action_send_now_sms(self):
+ if not self.sms_force_send:
+ self.write({'sms_force_send': True})
+ return self.action_send_mail()
def action_test(self):
if self.mailing_type == 'sms':
@@ -166,6 +176,7 @@ class Mailing(models.Model):
'composition_mode': 'mass',
'mailing_id': self.id,
'mass_keep_log': self.keep_archives,
+ 'mass_force_send': self.sms_force_send,
'mass_sms_allow_unsubscribe': self.sms_allow_unsubscribe,
}
@@ -183,11 +194,6 @@ class Mailing(models.Model):
raise UserError(_('There is no recipients selected.'))
composer = self.env['sms.composer'].with_context(active_id=False).create(mailing._send_sms_get_composer_values(res_ids))
- # extra_context = self._get_mass_mailing_context()
-
- # auto-commit except in testing mode
- # auto_commit = not getattr(threading.currentThread(), 'testing', False)
- # composer.send_mail(auto_commit=auto_commit)
composer._action_send_sms()
mailing.write({'state': 'done', 'sent_date': fields.Datetime.now()})
return True