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':
'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',
_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,
}
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 = {
<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"