[IMP] better usability

bzr revid: fp@tinyerp.com-20140413201748-u8e26ef40dt7360i
This commit is contained in:
Fabien Pinckaers 2014-04-13 22:17:48 +02:00
parent 8d6e2b4a15
commit b1ccd56368
4 changed files with 21 additions and 21 deletions

View File

@ -40,7 +40,7 @@ class MassMailingList(osv.Model):
def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None):
result = dict.fromkeys(ids, 0)
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']
return result

View File

@ -87,7 +87,7 @@
<field name="res_model">mail.mass_mailing.contact</field>
<field name="view_type">form</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">
<p class="oe_view_nocontent_create">
Click to create a recipient.
@ -180,15 +180,17 @@
<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="Test Mailing" states="draft"/>
<button name="send_mail" type="object" states="draft,test"
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"/>
</header>
<div class="oe_form_box_info oe_text_center" attrs="{'invisible': [('scheduled', '=', 0)]}">
<p><strong>
<field name="scheduled" class="oe_inline"/>emails are in queue
and will be sent soon.
<field name="scheduled" class="oe_inline"/>
emails are in queue and will be sent soon.
</strong></p>
</div>
<sheet>
@ -236,16 +238,14 @@
<strong>
<field name="contact_nbr" class="oe_inline"/> Recipients
</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>
</group>
<notebook>
<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">
<p class="oe_view_nocontent_create oe_edit_only">
Click to design your email.

View File

@ -6,27 +6,24 @@ from openerp.osv import osv, fields
class TestMassMailing(osv.TransientModel):
_name = 'mail.mass_mailing.test'
_description = 'Tets Mailing Wizard'
_description = 'Sample Mail Wizard'
_columns = {
'email_to': fields.char(
'Emails', required=True,
'email_to': fields.char('Recipients', required=True,
help='Comma-separated list of email addresses.'),
'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):
Mail = self.pool['mail.mail']
for wizard in self.browse(cr, uid, ids, context=context):
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)
if not test_emails:
raise Warning('Please specify test email adresses.')
mail_ids = []
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)
body = tools.append_content_to_html(body, unsubscribe_url, plaintext=False, container_tag='p')
mail_values = {

View File

@ -6,12 +6,15 @@
<field name="name">mail.mass_mailing.test.form</field>
<field name="model">mail.mass_mailing.test</field>
<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>
<field name="email_to"/>
</group>
<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
<button string="Cancel" class="oe_link" special="cancel" />
</footer>