[IMP] mass_mailing: various usability improvements
authorThibault Delavallée <tde@openerp.com>
Thu, 20 Mar 2014 17:04:55 +0000 (18:04 +0100)
committerThibault Delavallée <tde@openerp.com>
Thu, 20 Mar 2014 17:04:55 +0000 (18:04 +0100)
- See recipients on mailing form view: now opens the recipients in a popup,
- Added a minimal form view for the contact list, used in the actions to create
after choosing filter / domain / recipients, to avoid confusing the user,
- Various small fixes in kanban view of campaign,
- contact_list_ids m2m is now no_create, because there is a button to do it
properly
- changing model now reset the template

bzr revid: tde@openerp.com-20140320170455-6vvudpin2bsp8ida

addons/mass_mailing/models/mass_mailing.py
addons/mass_mailing/views/mass_mailing.xml
addons/mass_mailing/views/res_partner.xml

index dfaad61..a713d14 100644 (file)
@@ -127,9 +127,9 @@ class MassMailingList(osv.Model):
     def on_change_model(self, cr, uid, ids, model, context=None):
         values = {}
         if model == 'mail.mass_mailing.contact':
-            values.update(domain=False, filter_id=False)
+            values.update(domain=False, filter_id=False, template_id=False)
         else:
-            values.update(filter_id=False)
+            values.update(filter_id=False, template_id=False)
         return {'value': values}
 
     def on_change_filter_id(self, cr, uid, ids, filter_id, context=None):
@@ -141,6 +141,13 @@ class MassMailingList(osv.Model):
             values['domain'] = False
         return {'value': values}
 
+    def on_change_domain(self, cr, uid, ids, domain, model, context=None):
+        if domain is False:
+            return {'value': {'contact_nbr': 0}}
+        else:
+            domain = eval(domain)
+            return {'value': {'contact_nbr': self.pool[model].search(cr, uid, domain, context=context, count=True)}}
+
     def action_see_records(self, cr, uid, ids, context=None):
         contact_list = self.browse(cr, uid, ids[0], context=context)
         ctx = dict(context)
@@ -546,7 +553,7 @@ class MassMailing(osv.Model):
     #------------------------------------------------------
 
     def on_change_mailing_model(self, cr, uid, ids, mailing_model, context=None):
-        return {'value': {'contact_list_ids': []}}
+        return {'value': {'contact_list_ids': [], 'template_id': False, 'contact_nbr': 0}}
 
     def on_change_template_id(self, cr, uid, ids, template_id, context=None):
         values = {}
@@ -591,6 +598,7 @@ class MassMailing(osv.Model):
             'view_type': 'form',
             'view_mode': 'tree,form',
             'res_model': mailing.mailing_model,
+            'target': 'new',
             'domain': domain,
             'context': context,
         }
index dc86fb6..8ce75ae 100644 (file)
             </field>
         </record>
 
+        <record model="ir.ui.view" id="view_mail_mass_mailing_list_form_minimal">
+            <field name="name">mail.mass_mailing.list.form.minimal</field>
+            <field name="model">mail.mass_mailing.list</field>
+            <field name="priority">20</field>
+            <field name="arch" type="xml">
+                <form string="Contact List" version="7.0">
+                    <header>
+                        <button name="action_add_to_mailing" type="object"
+                            class="oe_highlight" string="Add to Mailing"
+                            invisible="not context.get('default_mass_mailing_id')"/>
+                    </header>
+                    <sheet>
+                        <group>
+                            <field name="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="contact_ids" invisible="1"/>
+                            <field name="filter_id" invisible="1"/>
+                            <field name="domain" on_change="on_change_domain(domain, model, context)" invisible="1"/>
+                        </group>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+
         <record model="ir.ui.view" id="view_mail_mass_mailing_list_form">
             <field name="name">mail.mass_mailing.list.form</field>
             <field name="model">mail.mass_mailing.list</field>
                             <field name="filter_id"
                                 on_change="on_change_filter_id(filter_id, context)"
                                 attrs="{'invisible': [('model', '=', 'mail.mass_mailing.contact')]}"/>
-                            <field name="domain"/>
-                                <!-- attrs="{'invisible': ['|', ('model', '=', 'mail.mass_mailing.contact'), ('filter_id', '!=', False)]}"/> -->
+                            <field name="domain" on_change="on_change_domain(domain, model, context)"/>
                         </group>
                     </sheet>
                 </form>
                                 </div>
                                 <field name="email_from"/>
                                 <field name="reply_to"/>
-                                <field name="email_to" widget="many2many_tags"/>
+                                <label for="email_to"/>
+                                <div>
+                                    <field name="email_to" widget="many2many_tags" nolabel="1"/>
+                                    Those addresses will be used when testing the mailing.
+                                </div>
                             </group>
                             <group>
                                 <p>Here be some graphs</p>
                                 <group>
                                     <label for="contact_list_ids" string="Selected Lists"/>
                                     <div>
-                                        <field name="contact_list_ids" widget="many2many_tags" nolabel="1"/>
+                                        <field name="contact_list_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
                                         <button string='Create a New List' class="oe_inline oe_link" type='object' name='action_new_list'/>
                                     </div>
                                 </group>
                                     <div>
                                         <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)"
                                             t-att-title="record.user_id.value" width="48" height="48o" class="oe_kanban_avatar oe_kanban_header_right"/>
-                                        <h3>
-                                            <field name="name"/>
-                                        </h3>
+                                        <h3 style="margin-bottom: 8px;"><field name="name"/></h3>
                                         <span class="oe_tag"><field name="category_id"/></span>
                                         <a name="%(action_view_mass_mailings_from_campaign)d" type="action"
                                             class="oe_mailings">
-                                            <h4><t t-raw="record.mass_mailing_ids.raw_value.length"/> Mailings</h4>
+                                            <h4 style="margin-top: 8px;"><t t-raw="record.mass_mailing_ids.raw_value.length"/> Mailings</h4>
                                         </a>
                                     </div>
                                     <div class="oe_clear"></div>
index 646b623..79e82d8 100644 (file)
             target="current"
             key2="client_action_multi"
             id="action_partner_to_mailing_list"
-            context="{'default_mass_mailing_id': context.get('default_mass_mailing_id')}"/>
+            view_id="mass_mailing.view_mail_mass_mailing_list_form_minimal"
+            context="{
+    'default_mass_mailing_id': context.get('default_mass_mailing_id'),
+    'default_model': 'res.partner'}"/>
 
     </data>
 </openerp>