diff options
| author | xO-Tx <mou@odoo.com> | 2020-06-15 07:49:43 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-08-11 14:38:33 +0000 |
| commit | f7862cd2b5cfd333688b219a64034e24f7d2e5a1 (patch) | |
| tree | 4860e137aaa75e2e03a2ad778bf08a2f7e16cb52 /addons/mass_mailing_sms/models/mailing_mailing.py | |
| parent | 6e8f4ff3ead93ad1e9294b0ebed8d60e4e4bf1ce (diff) | |
[IMP] mass_mailing[_sms]: update subject and allow emoji support for sms content
PURPOSE
Subject field on mailing has not the same use in email marketing (subject of
emails) and in SMS maketing (used internally as there is no subject in SMS).
Purpose of this commit is to improve mailing form view to better distinguish
email and SMS flows.
SPECIFICATIONS
This commit changes helper for mailing subject and update its label according
to mailing_type (mail or sms), as well as the sms content field to enable emoji
support in mailing subjects. This is done through a fake sms_subject field
that is a text without emojis while standard subject allows emojis. Helpers
depends on the displayed field.
Override CRUD to synchronize sms_subject on subject to have only one field
used to store data.
Also allow emojis in SMS content, suing the enable_emojis option.
LINKS
Task ID-2224393
PR #49096
Diffstat (limited to 'addons/mass_mailing_sms/models/mailing_mailing.py')
| -rw-r--r-- | addons/mass_mailing_sms/models/mailing_mailing.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/addons/mass_mailing_sms/models/mailing_mailing.py b/addons/mass_mailing_sms/models/mailing_mailing.py index cd0e6060f6f..ee1c11e20db 100644 --- a/addons/mass_mailing_sms/models/mailing_mailing.py +++ b/addons/mass_mailing_sms/models/mailing_mailing.py @@ -24,6 +24,15 @@ class Mailing(models.Model): mailing_type = fields.Selection(selection_add=[ ('sms', 'SMS') ], ondelete={'sms': 'set default'}) + + # 'sms_subject' added to override 'subject' field (string attribute should be labelled "Title" when mailing_type == 'sms'). + # 'sms_subject' should have the same helper as 'subject' field when 'mass_mailing_sms' installed. + # otherwise 'sms_subject' will get the old helper from 'mass_mailing' module. + # overriding 'subject' field helper in this model is not working, since the helper will keep the new value + # even when 'mass_mailing_sms' removed (see 'mailing_mailing_view_form_sms' for more details). + sms_subject = fields.Char('Title', help='For an Email, Subject your Recipients will see in their inbox.\n' + 'For an SMS Text Message, internal Title of the Message.', + related='subject', translate=True, readonly=False) # sms options body_plaintext = fields.Text('SMS Body', compute='_compute_body_plaintext', store=True, readonly=False) sms_template_id = fields.Many2one('sms.template', string='SMS Template', ondelete='set null') @@ -75,6 +84,17 @@ class Mailing(models.Model): # -------------------------------------------------- + # ORM OVERRIDES + # -------------------------------------------------- + + @api.model + def create(self, values): + # Get subject from "sms_subject" field when SMS installed (used to build the name of record in the super 'create' method) + if values.get('mailing_type') == 'sms' and values.get('sms_subject'): + values['subject'] = values['sms_subject'] + return super(Mailing, self).create(values) + + # -------------------------------------------------- # BUSINESS / VIEWS ACTIONS # -------------------------------------------------- |
