[IMP] mail.compose.message: now proposes to work on active_domain
authorThibault Delavallée <tde@openerp.com>
Mon, 22 Jul 2013 11:23:06 +0000 (13:23 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 22 Jul 2013 11:23:06 +0000 (13:23 +0200)
bzr revid: tde@openerp.com-20130722112306-r1u77tyqzk4bknrb

addons/mail/wizard/mail_compose_message.py
addons/mail/wizard/mail_compose_message_view.xml

index 7685a27..02fac7f 100644 (file)
@@ -73,6 +73,7 @@ class mail_compose_message(osv.TransientModel):
         res_id = context.get('default_res_id', context.get('active_id'))
         message_id = context.get('default_parent_id', context.get('message_id', context.get('active_id')))
         active_ids = context.get('active_ids')
+        result['active_domain'] = '%s' % context.get('active_domain', [])
 
         # get default values according to the composition mode
         if composition_mode == 'reply':
@@ -112,6 +113,8 @@ class mail_compose_message(osv.TransientModel):
         'partner_ids': fields.many2many('res.partner',
             'mail_compose_message_res_partner_rel',
             'wizard_id', 'partner_id', 'Additional contacts'),
+        'use_active_domain': fields.boolean('Use active domain'),
+        'active_domain': fields.char('Active domain', readonly=True),
         'post': fields.boolean('Post a copy in the document',
             help='Post a copy of the message on the document communication history.'),
         'notify': fields.boolean('Notify followers',
@@ -127,9 +130,7 @@ class mail_compose_message(osv.TransientModel):
     _defaults = {
         'composition_mode': 'comment',
         'body': lambda self, cr, uid, ctx={}: '',
-        'subject': lambda self, cr, uid, ctx={}: False,
         'partner_ids': lambda self, cr, uid, ctx={}: [],
-        'notify': lambda self, cr, uid, ctx={}: False,
         'post': lambda self, cr, uid, ctx={}: True,
         'same_thread': lambda self, cr, uid, ctx={}: True,
     }
@@ -238,8 +239,14 @@ class mail_compose_message(osv.TransientModel):
                 context['thread_model'] = wizard.model
                 active_model_pool = self.pool['mail.thread']
 
-            # wizard works in batch mode: [res_id] or active_ids
-            res_ids = active_ids if mass_mail_mode and wizard.model and active_ids else [wizard.res_id]
+            # wizard works in batch mode: [res_id] or active_ids or active_domain
+            if mass_mail_mode and wizard.use_active_domain and wizard.model:
+                res_ids = self.pool[wizard.model].search(cr, uid, eval(wizard.active_domain), context=context)
+            elif mass_mail_mode and wizard.model and active_ids:
+                res_ids = active_ids
+            else:
+                res_ids = [wizard.res_id]
+
             for res_id in res_ids:
                 # mail.message values, according to the wizard options
                 post_values = {
index 1ca07b6..c8c877e 100644 (file)
@@ -25,6 +25,9 @@
                         <field name="reply_to" placeholder="Email address te redirect replies..."
                             attrs="{'invisible':['|', ('same_thread', '=', True), ('composition_mode', '!=', 'mass_mail')],
                                     'required':[('same_thread', '!=', True)]}"/>
+                        <field name="use_active_domain" groups="base.group_no_one"
+                            attrs="{'invisible': [('composition_mode', '!=', 'mass_mail')]}"/>
+                        <field name="active_domain" attrs="{'invisible': [('use_active_domain', '=', False)]}"/>
                         <label for="partner_ids" string="Recipients"
                             attrs="{'invisible':[('composition_mode', '=', 'mass_mail')]}"/>
                         <div groups="base.group_user"