[IMP] sms - mass_mailing_sms : unsubscribe sms improvement

- In the sms marketing, the sms_allow_unsubscribe is now False by default
and move the field in the setting page.

- Improve the unsubscribe link for the sms : adding "\nSTOP SMS : "
message before the link.

TASK_ID : 2075733
This commit is contained in:
ryv-odoo
2019-09-30 14:28:28 +00:00
parent 2d5260e11b
commit b002973f0e
3 changed files with 6 additions and 4 deletions
@@ -23,7 +23,7 @@ class Mailing(models.Model):
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)
sms_allow_unsubscribe = fields.Boolean('Include opt-out link', default=False)
@api.onchange('mailing_type')
def _onchange_mailing_type(self):
@@ -106,10 +106,12 @@
<field name="body_plaintext" widget="sms_widget" attrs="{'required': [('mailing_type', '=', 'sms')]}"/>
<group>
<field name="sms_force_send" invisible="1"/>
<field name="sms_allow_unsubscribe"/>
</group>
</page>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="sms_allow_unsubscribe"/>
</xpath>
<!-- Option page tweaks -->
<xpath expr="//field[@name='email_from']" position="attributes">
<attribute name="attrs">{
@@ -3,7 +3,7 @@
import werkzeug.urls
from odoo import fields, models
from odoo import fields, models, _
class SMSComposer(models.TransientModel):
@@ -45,7 +45,7 @@ class SMSComposer(models.TransientModel):
trace_values['ignored'] = fields.Datetime.now()
else:
if self.mass_sms_allow_unsubscribe:
sms_values['body'] = '%s %s' % ((sms_values['body'] or ''), self._get_unsubscribe_url(record.id, trace_code, sms_values['number']))
sms_values['body'] = '%s\n%s' % (sms_values['body'] or '', _('STOP SMS : %s') % self._get_unsubscribe_url(record.id, trace_code, sms_values['number']))
return trace_values
def _get_blacklist_record_ids(self, records, recipients_info):