[IMP] mass_mailing: usability improvements
- from mass_mailing, creating or editing a template now goes through a wizard to avoid tweaking too much the email.template view. This allows an easier management of templates and their link with mailings. - moved email.template minimal form view from email_tmeplate to mass_mailing, because it is the sole module to use it. Tweaked it a bit by the way. - removed dead code about actions not used anymore in mass_mailing - empty list help on mail.mass_mailing.list - various small usability fixes bzr revid: tde@openerp.com-20140327130827-h9dy2m6mq10gzg1s
This commit is contained in:
parent
dc7398fdd3
commit
dae3551132
|
@ -80,40 +80,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_form_minimal">
|
||||
<field name="name">email.template.form.minimal</field>
|
||||
<field name="model">email.template</field>
|
||||
<field name="priority">32</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Templates" version="7.0">
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" required="True"/>
|
||||
<field name="model_id" required="1" options="{'no_open': True, 'no_create': True}"
|
||||
on_change="onchange_model_id(model_id)"/>
|
||||
<field name="model" invisible="True"/>
|
||||
<field name="use_default_to" invisible="True"/>
|
||||
</group>
|
||||
<group>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button name="%(wizard_email_template_preview)d" string="Preview"
|
||||
type="action" target="new"
|
||||
context="{'template_id':active_id}"/>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Body">
|
||||
<field name="body_html" nolabel="1"/>
|
||||
<field name="attachment_ids" widget="many2many_binary"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_tree">
|
||||
<field name="name">email.template.tree</field>
|
||||
<field name="model">email.template</field>
|
||||
|
|
|
@ -42,6 +42,7 @@ professional emails and reuse templates in a few clicks.
|
|||
'data/mail_data.xml',
|
||||
'data/mass_mailing_data.xml',
|
||||
'wizard/mail_compose_message_view.xml',
|
||||
'wizard/create_template_view.xml',
|
||||
'views/mass_mailing.xml',
|
||||
'views/res_config.xml',
|
||||
'views/res_partner.xml',
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<!-- <data noupdate="1"> -->
|
||||
<data>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="mass_mail_template_1" model="email.template">
|
||||
<field name="name">Partner Newsletter 1</field>
|
||||
|
|
|
@ -463,7 +463,7 @@ class MassMailing(osv.Model):
|
|||
),
|
||||
# mailing options
|
||||
'email_from': fields.char('From'),
|
||||
'email_to': fields.char('Test Emails'),
|
||||
'test_email_to': fields.char('Test Emails'),
|
||||
'reply_to': fields.char('Reply To'),
|
||||
'mailing_model': fields.selection(_mailing_model, string='Type', required=True),
|
||||
'contact_list_ids': fields.many2many(
|
||||
|
@ -625,43 +625,6 @@ class MassMailing(osv.Model):
|
|||
'context': context,
|
||||
}
|
||||
|
||||
def action_template_new(self, cr, uid, ids, context=None):
|
||||
mailing = self.browse(cr, uid, ids[0], context=context)
|
||||
view_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'email_template.email_template_form_minimal')
|
||||
ctx = dict(
|
||||
context,
|
||||
default_model=mailing.mailing_model,
|
||||
default_use_in_mass_mailing=True,
|
||||
default_use_default_to=True,
|
||||
default_name=mailing.name,
|
||||
)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.template',
|
||||
'view_id': view_id,
|
||||
'context': ctx,
|
||||
}
|
||||
|
||||
def action_template_copy(self, cr, uid, ids, context=None):
|
||||
mailing = self.browse(cr, uid, ids[0], context=context)
|
||||
if not mailing.template_id:
|
||||
return False
|
||||
new_tpl_id = self.pool['email.template'].copy(cr, uid, mailing.template_id.id, context=context)
|
||||
self.write(cr, uid, [mailing.id], {'template_id': new_tpl_id}, context=context)
|
||||
view_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'email_template.email_template_form_minimal')
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.template',
|
||||
'res_id': new_tpl_id,
|
||||
'view_id': view_id,
|
||||
'target': 'new',
|
||||
'context': context,
|
||||
}
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email Sending
|
||||
#------------------------------------------------------
|
||||
|
@ -744,7 +707,7 @@ class MassMailing(osv.Model):
|
|||
if not mailing.template_id:
|
||||
raise Warning('Please specifiy a template to use.')
|
||||
# res_ids = self._set_up_test_mailing(cr, uid, mailing.mailing_model, context=context)
|
||||
test_emails = tools.email_split(mailing.email_to)
|
||||
test_emails = tools.email_split(mailing.test_email_to)
|
||||
if not test_emails:
|
||||
raise Warning('Please specifiy test email adresses.')
|
||||
mail_ids = []
|
||||
|
|
|
@ -14,19 +14,39 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="email_template_form_minimal_mass_mailing" model="ir.ui.view">
|
||||
<field name="name">email.template.form.minimal.mass.mailing</field>
|
||||
<record model="ir.ui.view" id="email_template_form_minimal">
|
||||
<field name="name">email.template.form.minimal</field>
|
||||
<field name="model">email.template</field>
|
||||
<field name="inherit_id" ref="email_template.email_template_form_minimal"/>
|
||||
<field name="priority">32</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='model_id']" position="after">
|
||||
<label for="use_in_mass_mailing"/>
|
||||
<div>
|
||||
<field name="use_in_mass_mailing"/>
|
||||
<p>Choosing this option makes the template available for use
|
||||
in the mailings. It will also appear in the 'Mail Templates' menu.</p>
|
||||
</div>
|
||||
</xpath>
|
||||
<form string="Templates" version="7.0">
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" required="True"/>
|
||||
<field name="model_id" required="1" options="{'no_open': True, 'no_create': True}"
|
||||
on_change="onchange_model_id(model_id)"
|
||||
domain="[('model', 'in', ['res.partner', 'mail.mass_mailing.contact'])]"/>
|
||||
<field name="model" invisible="True"/>
|
||||
<field name="use_default_to" invisible="1"/>
|
||||
<field name="use_in_mass_mailing" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button name="%(email_template.wizard_email_template_preview)d" string="Preview"
|
||||
type="action" target="new"
|
||||
context="{'template_id':active_id}"/>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Body">
|
||||
<field name="body_html" nolabel="1"/>
|
||||
<field name="attachment_ids" widget="many2many_binary"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
@ -82,21 +102,23 @@ in the mailings. It will also appear in the 'Mail Templates' menu.</p>
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_email_template">
|
||||
<record model="ir.actions.act_window" id="action_email_template_marketing">
|
||||
<field name="name">Templates</field>
|
||||
<field name="res_model">email.template</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="domain" eval="[('use_in_mass_mailing', '=', True)]"/>
|
||||
<field name="context">{
|
||||
'search_default_use_in_mass_mailing': 1,
|
||||
'form_view_ref': 'email_template.email_template_form_minimal',
|
||||
'form_view_ref': 'mass_mailing.email_template_form_minimal',
|
||||
'default_use_default_to': True,
|
||||
'default_use_in_mass_mailing': True,
|
||||
}</field>
|
||||
</record>
|
||||
|
||||
<!-- Add Templates in Marketing / Mass mailing menu -->
|
||||
<menuitem name="Mail Templates" id="menu_email_template"
|
||||
parent="mass_mailing_campaign" sequence="3"
|
||||
action="action_email_template"/>
|
||||
action="action_email_template_marketing"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -68,11 +68,11 @@
|
|||
<field name="context">{'search_default_not_opt_out': 1}</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Mailing Contacts" id="menu_email_mass_mailing_contacts"
|
||||
<menuitem name="Contacts" id="menu_email_mass_mailing_contacts"
|
||||
parent="mass_mailing_list" sequence="50"
|
||||
action="action_view_mass_mailing_contacts"/>
|
||||
|
||||
<!-- Create a Mailing List from Contyacts-->
|
||||
<!-- Create a Mailing List from Contacts-->
|
||||
<act_window name="Create Mailing List"
|
||||
res_model="mail.mass_mailing.list"
|
||||
src_model="mail.mass_mailing.contact"
|
||||
|
@ -116,18 +116,18 @@
|
|||
<form string="Contact List" version="7.0">
|
||||
<header>
|
||||
<button name="action_add_to_mailing" type="object"
|
||||
class="oe_highlight" string="Add to Mailing"
|
||||
class="oe_highlight" string="Continue to Mailing"
|
||||
invisible="not context.get('default_mass_mailing_id')"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="name" string="Mailing List Name"/>
|
||||
<label for="contact_nbr"/>
|
||||
<div>
|
||||
<field name="contact_nbr" nolabel="1" class="oe_inline"/>
|
||||
<button name="action_see_records" type="object" class="oe_link" string="contacts"/>
|
||||
</div>
|
||||
<field name="model" on_change="on_change_model(model, context)" readonly="1"/>
|
||||
<field name="model" on_change="on_change_model(model, context)" invisible="1"/>
|
||||
<field name="contact_ids" invisible="1"/>
|
||||
<field name="filter_id" invisible="1"/>
|
||||
<field name="domain" on_change="on_change_domain(domain, model, context)" invisible="1"/>
|
||||
|
@ -178,6 +178,12 @@
|
|||
<field name="res_model">mail.mass_mailing.list</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click here to create a new mailing list.
|
||||
</p><p>
|
||||
Mailing lists allows you to to manage customers and contacts easily and to send to mailings in a single click.
|
||||
</p></field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Contact Lists" id="menu_email_mass_mailing_lists"
|
||||
|
@ -228,8 +234,6 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Mass Mailing" version="7.0">
|
||||
<header>
|
||||
<button name="send_mail_test" type="object"
|
||||
class="oe_highlight" string="Test Mailing"/>
|
||||
<button name="send_mail" type="object"
|
||||
class="oe_highlight" string="Send to All"/>
|
||||
<field name="state" widget="statusbar" clickable="True"/>
|
||||
|
@ -246,11 +250,13 @@
|
|||
options="{'no_create': True, 'no_open': True}"
|
||||
on_change="on_change_template_id(template_id, context)"/>
|
||||
<button string='Create a New Template' class='oe_inline oe_link oe_edit_only'
|
||||
type='object' name='action_template_new'
|
||||
attrs="{'invisible': [('template_id', '!=', False)]}"/>
|
||||
<button string='Copy and Edit Template' class='oe_inline oe_link oe_edit_only'
|
||||
type='object' name='action_template_copy'
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"/>
|
||||
type='action' name='%(action_mailing_email_template)d'
|
||||
attrs="{'invisible': [('template_id', '!=', False)]}"
|
||||
context="{'default_mass_mailing_id': active_id}"/>
|
||||
<button string='Edit this Email' class='oe_inline oe_link oe_edit_only'
|
||||
type='action' name='%(action_mailing_email_template)d'
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"
|
||||
context="{'default_mass_mailing_id': active_id, 'default_template_id': template_id}"/>
|
||||
<div style="max-width: 300px !important;">
|
||||
<field name="body_html" class="form_html_preview" nolabel="1"
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"/>
|
||||
|
@ -258,24 +264,26 @@
|
|||
</div>
|
||||
<field name="email_from"/>
|
||||
<field name="reply_to"/>
|
||||
<label for="email_to"/>
|
||||
<div>
|
||||
<field name="email_to" nolabel="1"/>
|
||||
Those addresses will be used when testing the mailing.
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<p>Here be some graphs</p>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<label for="test_email_to"/>
|
||||
<div>
|
||||
<field name="test_email_to" nolabel="1" clcass="oe_inline"/>
|
||||
<span class="oe_grey">Comma-separated email addresses for testing purpose.</span>
|
||||
<button string='Test Mailing' class='oe_inline oe_link' style='margin-left: 8px;'
|
||||
type='object' name='send_mail_test'/>
|
||||
</div>
|
||||
<label for="contact_list_ids" string="Recipients"/>
|
||||
<div>
|
||||
<field name="contact_nbr" class="oe_inline" readonly="True"/>
|
||||
<field name="mailing_model" class="oe_inline"
|
||||
on_change='on_change_mailing_model(mailing_model, context)'/>
|
||||
<span>selected</span>
|
||||
<button name="action_see_recipients" type="object" string="See Recipients" class="oe_link"/>
|
||||
<button name="action_see_recipients" type="object" string="See Recipients" class="oe_link" style='margin-left: 8px;'/>
|
||||
<group>
|
||||
<label for="contact_list_ids" string="Selected Lists"/>
|
||||
<div>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import create_template
|
||||
import mail_compose_message
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
|
||||
class EmailTemplateWizard(osv.TransientModel):
|
||||
"""A wizard allowing to create an email.template from a mass mailing. This wizard
|
||||
allows to simplify and direct the user in the creation of its template without
|
||||
having to tune or hack the email.template model. """
|
||||
_name = 'mailing.email.template.wizard'
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
res = super(EmailTemplateWizard, self).default_get(cr, uid, fields, context=context)
|
||||
if res.get('mass_mailing_id') and not 'name' in res:
|
||||
mailing_ng = self.pool['mail.mass_mailing'].name_get(cr, uid, [res.get('mass_mailing_id')], context=context)
|
||||
res['name'] = mailing_ng[0][1]
|
||||
return res
|
||||
|
||||
def _get_model_list(self, cr, uid, context=None):
|
||||
return self.pool['mail.mass_mailing']._get_mailing_model(cr, uid, context=context)
|
||||
|
||||
# indirections for inheritance
|
||||
_model_list = lambda self, *args, **kwargs: self._get_model_list(*args, **kwargs)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True),
|
||||
'body': fields.html('Body'),
|
||||
'template_id': fields.many2one('email.template', 'Basis Template'),
|
||||
'mass_mailing_id': fields.many2one('mail.mass_mailing', 'Mass Mailing', required=True),
|
||||
'attachment_ids': fields.many2many(
|
||||
'ir.attachment', 'email_template_wizard_attachment_rel', 'email_template_id',
|
||||
'attachment_id', 'Attachments'),
|
||||
}
|
||||
|
||||
def on_change_template_id(self, cr, uid, ids, template_id, context=None):
|
||||
if template_id:
|
||||
template = self.pool['email.template'].browse(cr, uid, template_id, context=context)
|
||||
return {'value': {'body': template.body_html, 'attachment_ids': [(4, att.id) for att in template.attachment_ids]}}
|
||||
return {}
|
||||
|
||||
def create_template(self, cr, uid, ids, context=None):
|
||||
EmailTemplate = self.pool['email.template']
|
||||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
model_ids = self.pool['ir.model'].search(cr, uid, [('model', '=', wizard.mass_mailing_id.mailing_model)], context=context)
|
||||
values = {
|
||||
'name': wizard.name,
|
||||
'model_id': model_ids[0],
|
||||
'body_html': wizard.body,
|
||||
'use_in_mass_mailing': True,
|
||||
'use_default_to': True,
|
||||
'attachment_ids': [(4, attach.id) for attach in wizard.attachment_ids],
|
||||
}
|
||||
tpl_id = EmailTemplate.create(cr, uid, values, context=context)
|
||||
self.pool['mail.mass_mailing'].write(cr, uid, [wizard.mass_mailing_id.id], {'template_id': tpl_id}, context=context)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mail.mass_mailing',
|
||||
'res_id': wizard.mass_mailing_id.id,
|
||||
'target': 'current',
|
||||
'context': context,
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_mailing_email_template_form">
|
||||
<field name="name">mailing.email.template.wizard.form</field>
|
||||
<field name="model">mailing.email.template.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Mass Mailing Template" version="7.0">
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="mass_mailing_id" readonly="1"/>
|
||||
<field name="template_id" invisible="1"
|
||||
on_change="on_change_template_id(template_id, context)"/>
|
||||
</group>
|
||||
<group>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button name="%(email_template.wizard_email_template_preview)d" string="Preview"
|
||||
type="action" target="new"
|
||||
context="{'template_id':active_id}"/>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Body">
|
||||
<field name="body" nolabel="1"/>
|
||||
<field name="attachment_ids" widget="many2many_binary"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<footer>
|
||||
<button string="Create" name="create_template" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_mailing_email_template" model="ir.actions.act_window">
|
||||
<field name="name">Mass Mailing Template</field>
|
||||
<field name="res_model">mailing.email.template.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue