diff options
| author | Thibault Delavallée <tde@odoo.com> | 2018-12-13 11:47:03 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-01-17 10:33:07 +0000 |
| commit | f50fbc6d168f0d17fa1e932b4ecc968a92b02b65 (patch) | |
| tree | d1e028340c4edea09cd5ca1e1a2743bfa23f3875 /addons/mass_mailing/models | |
| parent | 2428ce871d3de2e115fdc50cddb587f6bd0fa242 (diff) | |
[IMP] mass_mailing: differentiate mailing name from emails subject
Purpose of this task is to allow marketing people to differentiate the
mailing name (internal reference) from the subject used in the mailing
emails.
Mailing name is actually the UTM source name as mass mailing inherits
from it. Being able to edit it independently from the subject allows
to better categorize / filter mailings without sending technical terms
to customers. Marketing users could also change and tweak mailing subject
without disorganizing the pipe and changing the URM source name.
Demo data are updated accordingly to have both subject and mailing
names.
This commit is linked to task ID 1917602 and PR #29514.
Diffstat (limited to 'addons/mass_mailing/models')
| -rw-r--r-- | addons/mass_mailing/models/mass_mailing.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index c3d872fb1a7..f9d95c893d9 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -451,6 +451,7 @@ class MassMailing(models.Model): return res active = fields.Boolean(default=True) + subject = fields.Char('Subject', help='Subject of emails to send', required=True) email_from = fields.Char(string='From', required=True, default=lambda self: self.env['mail.message']._get_default_from()) sent_date = fields.Datetime(string='Sent Date', oldname='date', copy=False) @@ -462,7 +463,7 @@ class MassMailing(models.Model): mass_mailing_campaign_id = fields.Many2one('mail.mass_mailing.campaign', string='Mass Mailing Campaign') campaign_id = fields.Many2one('utm.campaign', string='Campaign', help="This name helps you tracking your different campaign efforts, e.g. Fall_Drive, Christmas_Special") - source_id = fields.Many2one('utm.source', string='Subject', required=True, ondelete='cascade', + source_id = fields.Many2one('utm.source', string='Source', required=True, ondelete='cascade', help="This is the link source, e.g. Search Engine, another domain, or name of email list") medium_id = fields.Many2one('utm.medium', string='Medium', help="This is the delivery method, e.g. Postcard, Email, or Banner Ad", default=lambda self: self.env.ref('utm.utm_medium_email')) @@ -622,6 +623,11 @@ class MassMailing(models.Model): self.mailing_domain = repr(mailing_domain) self.body_html = "on_change_model_and_list" + @api.onchange('subject') + def _onchange_subject(self): + if self.subject and not self.name: + self.name = self.subject + #------------------------------------------------------ # Technical stuff #------------------------------------------------------ @@ -629,9 +635,15 @@ class MassMailing(models.Model): @api.model def name_create(self, name): """ _rec_name is source_id, creates a utm.source instead """ - mass_mailing = self.create({'name': name}) + mass_mailing = self.create({'name': name, 'subject': name}) return mass_mailing.name_get()[0] + @api.model + def create(self, vals): + if vals.get('name') and not vals.get('subject'): + vals['subject'] = vals['name'] + return super(MassMailing, self).create(vals) + @api.multi @api.returns('self', lambda value: value.id) def copy(self, default=None): @@ -862,7 +874,7 @@ class MassMailing(models.Model): 'author_id': author_id, 'attachment_ids': [(4, attachment.id) for attachment in mailing.attachment_ids], 'body': mailing.convert_links()[mailing.id], - 'subject': mailing.name, + 'subject': mailing.subject, 'model': mailing.mailing_model_real, 'email_from': mailing.email_from, 'record_name': False, |
