[IMP] mass_mailing: testing the mailing is now done using a wizard, to avoid
bloating the mailing ofrm view bzr revid: tde@openerp.com-20140403125905-sq6ksthkahna29ud
This commit is contained in:
parent
1380f597a2
commit
b6eeedea7d
|
@ -44,6 +44,7 @@ professional emails and reuse templates in a few clicks.
|
|||
'wizard/mail_compose_message_view.xml',
|
||||
'wizard/create_template_view.xml',
|
||||
'wizard/create_list_view.xml',
|
||||
'wizard/test_mailing.xml',
|
||||
'views/mass_mailing.xml',
|
||||
'views/res_config.xml',
|
||||
'views/res_partner.xml',
|
||||
|
|
|
@ -493,7 +493,6 @@ class MassMailing(osv.Model):
|
|||
),
|
||||
# mailing options
|
||||
'email_from': fields.char('From'),
|
||||
'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(
|
||||
|
@ -687,6 +686,17 @@ class MassMailing(osv.Model):
|
|||
'context': context,
|
||||
}
|
||||
|
||||
def action_test_mailing(self, cr, uid, ids, context=None):
|
||||
ctx = dict(context, default_mass_mailing_id=ids[0])
|
||||
return {
|
||||
'name': _('Test Mailing'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mail.mass_mailing.test',
|
||||
'target': 'new',
|
||||
'context': ctx,
|
||||
}
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email Sending
|
||||
#------------------------------------------------------
|
||||
|
@ -781,31 +791,6 @@ class MassMailing(osv.Model):
|
|||
Mail.create(cr, uid, mail_values, context=context)
|
||||
return True
|
||||
|
||||
def send_mail_test(self, cr, uid, ids, context=None):
|
||||
Mail = self.pool['mail.mail']
|
||||
for mailing in self.browse(cr, uid, ids, context=context):
|
||||
if not mailing.template_id:
|
||||
raise Warning('Please specifiy a template to use.')
|
||||
test_emails = tools.email_split(mailing.test_email_to)
|
||||
if not test_emails:
|
||||
raise Warning('Please specifiy test email adresses.')
|
||||
mail_ids = []
|
||||
for test_mail in test_emails:
|
||||
body = mailing.template_id.body_html
|
||||
unsubscribe_url = self.get_unsubscribe_url(cr, uid, mailing.id, 0, email=test_mail, context=context)
|
||||
body = tools.append_content_to_html(body, unsubscribe_url, plaintext=False, container_tag='p')
|
||||
mail_values = {
|
||||
'email_from': mailing.email_from,
|
||||
'reply_to': mailing.reply_to,
|
||||
'email_to': test_mail,
|
||||
'subject': mailing.name,
|
||||
'body_html': body,
|
||||
'auto_delete': True,
|
||||
}
|
||||
mail_ids.append(Mail.create(cr, uid, mail_values, context=context))
|
||||
Mail.send(cr, uid, mail_ids, context=context)
|
||||
return True
|
||||
|
||||
|
||||
class MailMailStats(osv.Model):
|
||||
""" MailMailStats models the statistics collected about emails. Those statistics
|
||||
|
|
|
@ -203,6 +203,8 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Mass Mailing" version="7.0">
|
||||
<header>
|
||||
<button name="action_test_mailing" 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"/>
|
||||
|
@ -253,13 +255,6 @@
|
|||
</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>
|
||||
<group>
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
import create_list
|
||||
import create_template
|
||||
import test_mailing
|
||||
import mail_compose_message
|
||||
|
|
Loading…
Reference in New Issue