[IMP] mass_mailing: add email marketing tour
PURPOSE
Improve the Email Marketing tour and onboarding to create a "wow effect" when
users test the app.
SPECIFICATIONS
Create a tour for mass_mailing to let user visit Odoo Email Marketing through
a simple mailing creation flow.
This require the following functional changes
* by default, if user chooses to contact mailing lists and there is a single
mailing list available, add it as default value for chosen list;
* create a master mailing list data containing the admin user so that he can
easily follow the tour and test the mailing application;
LINKS
Task ID 2194876
Community PR odoo/odoo#48259
Upgrade PR odoo/upgrade#983
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
committed by
Thibault Delavallée
parent
ad828f4042
commit
c15f9efed0
@@ -17,6 +17,7 @@
|
||||
'web_editor',
|
||||
'web_kanban_gauge',
|
||||
'social_media',
|
||||
'web_tour',
|
||||
],
|
||||
'data': [
|
||||
'security/mass_mailing_security.xml',
|
||||
|
||||
@@ -13,5 +13,13 @@
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall" />
|
||||
</record>
|
||||
<record id="mailing_list_data" model="mailing.list">
|
||||
<field name="name">Newsletter</field>
|
||||
</record>
|
||||
<record id="mass_mailing_contact_0" model="mailing.contact">
|
||||
<field name="name" model="res.users" eval="obj().env.ref('base.user_admin').name"/>
|
||||
<field name="email" model="res.users" eval="obj().env.ref('base.user_admin').email"/>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mailing_list_data')])]"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -7,26 +7,21 @@
|
||||
<field name="name">SampleDoc.doc</field>
|
||||
</record>
|
||||
|
||||
<!-- Create mailing lists -->
|
||||
<record id="mass_mail_list_2" model="mailing.list">
|
||||
<field name="name">Imported Contacts</field>
|
||||
</record>
|
||||
|
||||
<!-- Create Contacts -->
|
||||
<record id="mass_mail_contact_1" model="mailing.contact">
|
||||
<field name="name">Aristide Antario</field>
|
||||
<field name="email">aa@example.com</field>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mass_mail_list_2')])]"/>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mailing_list_data')])]"/>
|
||||
</record>
|
||||
<record id="mass_mail_contact_2" model="mailing.contact">
|
||||
<field name="name">Beverly Bridge</field>
|
||||
<field name="email">bb@example.com</field>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mass_mail_list_2')])]"/>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mailing_list_data')])]"/>
|
||||
</record>
|
||||
<record id="mass_mail_contact_3" model="mailing.contact">
|
||||
<field name="name">Carol Cartridge</field>
|
||||
<field name="email">cc@example.com</field>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mass_mail_list_2')])]"/>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mailing_list_data')])]"/>
|
||||
</record>
|
||||
<record id="mass_mail_contact_4" model="mailing.contact">
|
||||
<field name="name">David Dawson</field>
|
||||
@@ -35,12 +30,12 @@
|
||||
<record id="mass_mail_contact_5" model="mailing.contact">
|
||||
<field name="name">Elsa Ericson</field>
|
||||
<field name="email">ee@example.com</field>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mass_mail_list_2')])]"/>
|
||||
<field name="list_ids" eval="[(6,0,[ref('mass_mailing.mailing_list_data')])]"/>
|
||||
</record>
|
||||
|
||||
<!-- Create Opt-out Records -->
|
||||
<record id="mass_mail_contact_list_rel_1" model="mailing.contact.subscription">
|
||||
<field name="list_id" ref="mass_mailing.mass_mail_list_2"/>
|
||||
<field name="list_id" ref="mass_mailing.mailing_list_data"/>
|
||||
<field name="contact_id" ref="mass_mailing.mass_mail_contact_4"/>
|
||||
<field name="opt_out">True</field>
|
||||
</record>
|
||||
|
||||
@@ -9,10 +9,9 @@ import random
|
||||
import re
|
||||
import threading
|
||||
from ast import literal_eval
|
||||
from base64 import b64encode
|
||||
from datetime import datetime
|
||||
|
||||
from odoo import api, fields, models, tools, _, SUPERUSER_ID
|
||||
from odoo import api, fields, models, tools, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.osv import expression
|
||||
|
||||
@@ -44,6 +43,16 @@ class MassMailing(models.Model):
|
||||
_inherits = {'utm.source': 'source_id'}
|
||||
_rec_name = "subject"
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
vals = super(MassMailing, self).default_get(fields)
|
||||
if 'contact_list_ids' in fields and not vals.get('contact_list_ids') and vals.get('mailing_model_id'):
|
||||
if vals.get('mailing_model_id') == self.env['ir.model']._get('mailing.list').id:
|
||||
mailing_list = self.env['mailing.list'].search([], limit=2)
|
||||
if len(mailing_list) == 1:
|
||||
vals['contact_list_ids'] = [(6, 0, [mailing_list.id])]
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def _get_default_mail_server_id(self):
|
||||
server_id = self.env['ir.config_parameter'].sudo().get_param('mass_mailing.mail_server_id')
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
odoo.define('mass_mailing.mass_mailing_tour', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var _t = core._t;
|
||||
var tour = require('web_tour.tour');
|
||||
var now = moment();
|
||||
|
||||
tour.register('mass_mailing_tour', {
|
||||
url: '/web',
|
||||
rainbowManMessage: _t('Congratulations, I love your first mailing. :)'),
|
||||
}, [tour.stepUtils.showAppsMenuItem(), {
|
||||
trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]',
|
||||
content: _t("Let's try the Email Marketing app."),
|
||||
width: 210,
|
||||
position: 'bottom',
|
||||
edition: 'enterprise',
|
||||
}, {
|
||||
trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]',
|
||||
content: _t("Let's try the Email Marketing app."),
|
||||
edition: 'community',
|
||||
}, {
|
||||
trigger: '.o-kanban-button-new',
|
||||
content: _t("Start by creating your first <b>Mailing</b>."),
|
||||
position: 'bottom',
|
||||
}, {
|
||||
trigger: 'input[name="subject"]',
|
||||
content: _t('Pick the <b>email subject</b>.'),
|
||||
position: 'right',
|
||||
run: 'text ' + now.format("MMMM") + " Newsletter",
|
||||
}, {
|
||||
trigger: 'div[name="contact_list_ids"] > .o_input_dropdown > input[type="text"]',
|
||||
run: 'click',
|
||||
auto: true,
|
||||
}, {
|
||||
trigger: 'li.ui-menu-item',
|
||||
run: 'click',
|
||||
auto: true,
|
||||
}, {
|
||||
trigger: 'div[name="body_arch"] iframe #newsletter',
|
||||
content: _t('Choose this <b>theme</b>.'),
|
||||
position: 'left',
|
||||
edition: 'enterprise',
|
||||
run: 'click',
|
||||
}, {
|
||||
trigger: 'div[name="body_arch"] iframe #default',
|
||||
content: _t('Choose this <b>theme</b>.'),
|
||||
position: 'right',
|
||||
edition: 'community',
|
||||
run: 'click',
|
||||
}, {
|
||||
trigger: 'div[name="body_arch"] iframe div.o_mail_block_paragraph',
|
||||
content: _t('Click on this paragraph to edit it.'),
|
||||
position: 'top',
|
||||
edition: 'enterprise',
|
||||
run: 'click',
|
||||
}, {
|
||||
trigger: 'div[name="body_arch"] iframe div.o_mail_block_title_text',
|
||||
content: _t('Click on this paragraph to edit it.'),
|
||||
position: 'top',
|
||||
edition: 'community',
|
||||
run: 'click',
|
||||
}, {
|
||||
trigger: 'button[name="action_test"]',
|
||||
content: _t("Test this mailing by sending a copy to yourself."),
|
||||
position: 'bottom',
|
||||
}, {
|
||||
trigger: 'button[name="send_mail_test"]',
|
||||
content: _t("Check the email address and click send."),
|
||||
position: 'bottom',
|
||||
}, {
|
||||
trigger: 'button[name="action_put_in_queue"]',
|
||||
content: _t("Ready for take-off!"),
|
||||
position: 'bottom',
|
||||
}, {
|
||||
trigger: '.btn-primary:contains("Ok")',
|
||||
content: _t("Don't worry, the mailing contact we created is an internal user."),
|
||||
position: 'bottom',
|
||||
run: "click",
|
||||
}, {
|
||||
trigger: '.o_back_button',
|
||||
content: _t("By using the <b>Breadcrumb</b>, you can navigate back to the overview."),
|
||||
position: 'bottom',
|
||||
run: 'click',
|
||||
}]
|
||||
);
|
||||
});
|
||||
@@ -6,7 +6,7 @@
|
||||
</a>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<t t-foreach="themes" t-as="theme">
|
||||
<a role="menuitem" href="#" class="dropdown-item">
|
||||
<a t-att-id="theme.name" role="menuitem" href="#" class="dropdown-item">
|
||||
<div class="o_thumb small" t-attf-style="background-image: url(#{theme.img}_small.png)"/>
|
||||
<div class="o_thumb large" t-attf-style="background-image: url(#{theme.img}_large.png)"/>
|
||||
<div class="o_thumb logo" t-attf-style="background-image: url(#{theme.img}_logo.png)"/>
|
||||
|
||||
@@ -38,6 +38,12 @@
|
||||
<link rel="stylesheet" type="text/scss" href="/mass_mailing/static/src/css/basic_theme_readonly.css"/>
|
||||
</template>
|
||||
|
||||
<template id="assets_common" name="Mass Mailing Assets Common" inherit_id="web.assets_common">
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javscript" src="/mass_mailing/static/src/js/tours/mass_mailing_tour.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="qunit_suite" inherit_id="web.qunit_suite_tests">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="mailing_type" widget="radio" options="{'horizontal': true}" invisible="1"
|
||||
attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}"/>
|
||||
<field name="subject" string="Subject" attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}" widget="char_emojis"/>
|
||||
<field name="subject" string="Subject" attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}" widget="char_emojis" placeholder="e.g. New Sale on all T-shirts"/>
|
||||
<label for="mailing_model_id" string="Recipients"/>
|
||||
<div name="mailing_model_id_container">
|
||||
<div class="row">
|
||||
|
||||
@@ -51,7 +51,7 @@ class TestMassMailPerformance(TestMassMailPerformanceBase):
|
||||
})
|
||||
|
||||
# runbot needs +50 compared to local
|
||||
with self.assertQueryCount(__system__=1913, marketing=1914):
|
||||
with self.assertQueryCount(__system__=1914, marketing=1915):
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertEqual(mailing.sent, 50)
|
||||
@@ -91,7 +91,7 @@ class TestMassMailBlPerformance(TestMassMailPerformanceBase):
|
||||
})
|
||||
|
||||
# runbot needs +62 compared to local
|
||||
with self.assertQueryCount(__system__=2240, marketing=2241):
|
||||
with self.assertQueryCount(__system__=2241, marketing=2242):
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertEqual(mailing.sent, 50)
|
||||
|
||||
Reference in New Issue
Block a user