[IMP] better usability
bzr revid: fp@tinyerp.com-20140413201748-u8e26ef40dt7360i
This commit is contained in:
parent
8d6e2b4a15
commit
b1ccd56368
|
@ -40,7 +40,7 @@ class MassMailingList(osv.Model):
|
||||||
def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None):
|
def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None):
|
||||||
result = dict.fromkeys(ids, 0)
|
result = dict.fromkeys(ids, 0)
|
||||||
mlc = self.pool.get('mail.mass_mailing.contact')
|
mlc = self.pool.get('mail.mass_mailing.contact')
|
||||||
for m in mlc.read_group(cr, uid, [('list_id','in',ids)], ['list_id'], ['list_id'], context=context):
|
for m in mlc.read_group(cr, uid, [('list_id','in',ids),('opt_out','!=',1)], ['list_id'], ['list_id'], context=context):
|
||||||
result[m['list_id'][0]] = m['list_id_count']
|
result[m['list_id'][0]] = m['list_id_count']
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
<field name="res_model">mail.mass_mailing.contact</field>
|
<field name="res_model">mail.mass_mailing.contact</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">tree</field>
|
||||||
<field name="context">{'search_default_list_id': active_id}</field>
|
<field name="context">{'search_default_list_id': active_id, 'search_default_not_opt_out': 1}</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="oe_view_nocontent_create">
|
<p class="oe_view_nocontent_create">
|
||||||
Click to create a recipient.
|
Click to create a recipient.
|
||||||
|
@ -180,15 +180,17 @@
|
||||||
<form string="Mass Mailing" version="7.0">
|
<form string="Mass Mailing" version="7.0">
|
||||||
<header>
|
<header>
|
||||||
<button name="action_test_mailing" type="object"
|
<button name="action_test_mailing" type="object"
|
||||||
class="oe_highlight" string="Test Mailing"/>
|
class="oe_highlight" string="Test Mailing" states="draft"/>
|
||||||
<button name="send_mail" type="object"
|
<button name="send_mail" type="object" states="draft,test"
|
||||||
class="oe_highlight" string="Send to All"/>
|
class="oe_highlight" string="Send to All"/>
|
||||||
|
<button name="action_test_mailing" type="object" states="test,done"
|
||||||
|
string="Send Test Sample"/>
|
||||||
<field name="state" widget="statusbar"/>
|
<field name="state" widget="statusbar"/>
|
||||||
</header>
|
</header>
|
||||||
<div class="oe_form_box_info oe_text_center" attrs="{'invisible': [('scheduled', '=', 0)]}">
|
<div class="oe_form_box_info oe_text_center" attrs="{'invisible': [('scheduled', '=', 0)]}">
|
||||||
<p><strong>
|
<p><strong>
|
||||||
<field name="scheduled" class="oe_inline"/>emails are in queue
|
<field name="scheduled" class="oe_inline"/>
|
||||||
and will be sent soon.
|
emails are in queue and will be sent soon.
|
||||||
</strong></p>
|
</strong></p>
|
||||||
</div>
|
</div>
|
||||||
<sheet>
|
<sheet>
|
||||||
|
@ -236,16 +238,14 @@
|
||||||
<strong>
|
<strong>
|
||||||
<field name="contact_nbr" class="oe_inline"/> Recipients
|
<field name="contact_nbr" class="oe_inline"/> Recipients
|
||||||
</strong>
|
</strong>
|
||||||
<button class="oe_link" type='object' name='action_domain_select' attrs="{'invisible': [('mailing_model', '=', 'mail.mass_mailing.contact')]}">
|
|
||||||
<span class="fa fa-arrow-right"> Change Selection</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Mail Body">
|
<page string="Mail Body">
|
||||||
<button name="action_edit_html" type="object" string="Design Email" class="oe_highlight"/>
|
<button name="action_edit_html" type="object" string="Design Email" class="oe_highlight" states="draft"/>
|
||||||
|
<button name="action_edit_html" type="object" string="Change Email Design" states="test"/>
|
||||||
<div attrs="{'invisible' : ['|', ('body_html','!=',False), ('mailing_domain', '!=', False)]}" class="oe_view_nocontent oe_clear">
|
<div attrs="{'invisible' : ['|', ('body_html','!=',False), ('mailing_domain', '!=', False)]}" class="oe_view_nocontent oe_clear">
|
||||||
<p class="oe_view_nocontent_create oe_edit_only">
|
<p class="oe_view_nocontent_create oe_edit_only">
|
||||||
Click to design your email.
|
Click to design your email.
|
||||||
|
|
|
@ -6,27 +6,24 @@ from openerp.osv import osv, fields
|
||||||
|
|
||||||
class TestMassMailing(osv.TransientModel):
|
class TestMassMailing(osv.TransientModel):
|
||||||
_name = 'mail.mass_mailing.test'
|
_name = 'mail.mass_mailing.test'
|
||||||
_description = 'Tets Mailing Wizard'
|
_description = 'Sample Mail Wizard'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'email_to': fields.char(
|
'email_to': fields.char('Recipients', required=True,
|
||||||
'Emails', required=True,
|
|
||||||
help='Comma-separated list of email addresses.'),
|
help='Comma-separated list of email addresses.'),
|
||||||
'mass_mailing_id': fields.many2one('mail.mass_mailing', 'Mailing', required=True),
|
'mass_mailing_id': fields.many2one('mail.mass_mailing', 'Mailing', required=True),
|
||||||
}
|
}
|
||||||
|
_defaults = {
|
||||||
|
'email_to': lambda self, cr, uid, ctx=None: self.pool['mail.message']._get_default_from(cr, uid, context=ctx),
|
||||||
|
}
|
||||||
|
|
||||||
def send_mail_test(self, cr, uid, ids, context=None):
|
def send_mail_test(self, cr, uid, ids, context=None):
|
||||||
Mail = self.pool['mail.mail']
|
Mail = self.pool['mail.mail']
|
||||||
for wizard in self.browse(cr, uid, ids, context=context):
|
for wizard in self.browse(cr, uid, ids, context=context):
|
||||||
mailing = wizard.mass_mailing_id
|
mailing = wizard.mass_mailing_id
|
||||||
if not mailing.template_id:
|
|
||||||
raise Warning('Please specify on your mailing the template to use.')
|
|
||||||
test_emails = tools.email_split(wizard.email_to)
|
test_emails = tools.email_split(wizard.email_to)
|
||||||
if not test_emails:
|
|
||||||
raise Warning('Please specify test email adresses.')
|
|
||||||
mail_ids = []
|
mail_ids = []
|
||||||
for test_mail in test_emails:
|
for test_mail in test_emails:
|
||||||
body = mailing.template_id.body_html
|
body = mailing.body_html
|
||||||
unsubscribe_url = self.pool['mail.mass_mailing'].get_unsubscribe_url(cr, uid, mailing.id, 0, email=test_mail, context=context)
|
unsubscribe_url = self.pool['mail.mass_mailing'].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')
|
body = tools.append_content_to_html(body, unsubscribe_url, plaintext=False, container_tag='p')
|
||||||
mail_values = {
|
mail_values = {
|
||||||
|
|
|
@ -6,12 +6,15 @@
|
||||||
<field name="name">mail.mass_mailing.test.form</field>
|
<field name="name">mail.mass_mailing.test.form</field>
|
||||||
<field name="model">mail.mass_mailing.test</field>
|
<field name="model">mail.mass_mailing.test</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Mailing Test" version="7.0">
|
<form string="Send a Sample Mail" version="7.0">
|
||||||
|
<p class="text-muted">
|
||||||
|
Send a sample of this mailing to the above of email addresses for test purpose.
|
||||||
|
</p>
|
||||||
<group>
|
<group>
|
||||||
<field name="email_to"/>
|
<field name="email_to"/>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button string="Test Mailing" name="send_mail_test" type="object" class="oe_highlight"/>
|
<button string="Send Sample Mail" name="send_mail_test" type="object" class="oe_highlight"/>
|
||||||
or
|
or
|
||||||
<button string="Cancel" class="oe_link" special="cancel" />
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
</footer>
|
</footer>
|
||||||
|
|
Loading…
Reference in New Issue