[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.
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
<field name="color" eval="1"/>
|
||||
</record>
|
||||
<record id="utm_source_0" model="utm.source">
|
||||
<field name="name">Newsleter</field>
|
||||
<field name="name">Newsletter 1</field>
|
||||
</record>
|
||||
<record id="mass_mail_campaign_1" model="mail.mass_mailing.campaign">
|
||||
<field name="name">Newsletter</field>
|
||||
@@ -70,7 +70,8 @@
|
||||
</record>
|
||||
|
||||
<record id="mass_mail_1" model="mail.mass_mailing">
|
||||
<field name="name">First Newsletter</field>
|
||||
<field name="name">Newsletter 1</field>
|
||||
<field name="subject" eval="'%s Newsletter' % (DateTime.today().strftime('%B'))"/>
|
||||
<field name="state">done</field>
|
||||
<field name="user_id" eval="ref('base.user_admin')"/>
|
||||
<field name="email_from">info@yourcompany.example.com</field>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -591,10 +591,8 @@
|
||||
</div>
|
||||
|
||||
<group>
|
||||
<label for="name" string="Subject"/>
|
||||
<div>
|
||||
<field name="name" nolabel="1"/>
|
||||
</div>
|
||||
<field name="name" required="1" string="Mailing Name"/>
|
||||
<field name="subject" string="Subject"/>
|
||||
<label for="mailing_model_id" string="Recipients"/>
|
||||
<div>
|
||||
<field name="mailing_model_id" widget="selection" required="1"/>
|
||||
@@ -645,6 +643,7 @@
|
||||
string="UTM Campaign"
|
||||
groups="base.group_no_one"/>
|
||||
<field name="source_id"
|
||||
readonly="1"
|
||||
string="Source"
|
||||
required="False"
|
||||
groups="base.group_no_one"/>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="mass_mail_lead_0" model="mail.mass_mailing">
|
||||
<field name="name">Lead Newsletter</field>
|
||||
<field name="name">Lead Recall</field>
|
||||
<field name="subject">We want to hear form you !</field>
|
||||
<field name="state">in_queue</field>
|
||||
<field name="user_id" ref="base.user_admin"/>
|
||||
<field name="schedule_date" eval="(DateTime.today() + relativedelta(days=5)).strftime('%Y-%m-%d %H:%M:%S')"/>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
<record id="mass_mail_sale_order_0" model="mail.mass_mailing">
|
||||
<field name="name">Sale Newsletter</field>
|
||||
<field name="name">Sale Promotion 1</field>
|
||||
<field name="subject">Our last promotions, just for you !</field>
|
||||
<field name="state">in_queue</field>
|
||||
<field name="user_id" ref="base.user_admin"/>
|
||||
<field name="schedule_date" eval="(DateTime.today() + relativedelta(days=5)).strftime('%Y-%m-%d %H:%M:%S')"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<field name="name">Search engine</field>
|
||||
</record>
|
||||
<record model="utm.source" id="utm_source_mailing">
|
||||
<field name="name">Mailing Partner</field>
|
||||
<field name="name">Lead Recall</field>
|
||||
</record>
|
||||
<record model="utm.source" id="utm_source_newsletter">
|
||||
<field name="name">Newsletter</field>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
<record id="utm_source_sale_order_0" model="utm.source">
|
||||
<field name="name">Sale Newsletter</field>
|
||||
<field name="name">Sale Promotion 1</field>
|
||||
</record>
|
||||
<record id="website_sale.website_sale_order_1" model="sale.order">
|
||||
<field name="campaign_id" ref="utm.utm_campaign_email_campaign_products"/>
|
||||
|
||||
Reference in New Issue
Block a user