diff options
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_compose_message.py | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 7bf4d47d1ff..6ab1f0e81ff 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -73,6 +73,11 @@ 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') + if 'active_domain' in context: # not context.get() because we want to keep global [] domains + result['use_active_domain'] = True + result['active_domain'] = '%s' % context.get('active_domain') + else: + result['active_domain'] = '' # get default values according to the composition mode if composition_mode == 'reply': @@ -112,6 +117,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', @@ -126,11 +133,9 @@ class mail_compose_message(osv.TransientModel): _defaults = { 'composition_mode': 'comment', - 'email_from': lambda self, cr, uid, ctx={}: self.pool.get('mail.mail')._get_default_from(cr, uid, context=ctx), '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, } @@ -158,7 +163,7 @@ class mail_compose_message(osv.TransientModel): return super(mail_compose_message, self).check_access_rule(cr, uid, ids, operation, context=context) - def _notify(self, cr, uid, newid, context=None): + def _notify(self, cr, uid, newid, context=None, force_send=False, user_signature=True): """ Override specific notify method of mail.message, because we do not want that feature in the wizard. """ return @@ -235,9 +240,18 @@ class mail_compose_message(osv.TransientModel): for wizard in self.browse(cr, uid, ids, context=context): mass_mail_mode = wizard.composition_mode == 'mass_mail' active_model_pool = self.pool[wizard.model if wizard.model else 'mail.thread'] + if not hasattr(active_model_pool, 'message_post'): + context['thread_model'] = wizard.model + active_model_pool = self.pool['mail.thread'] + + # 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] - # 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] for res_id in res_ids: # mail.message values, according to the wizard options post_values = { @@ -257,13 +271,15 @@ class mail_compose_message(osv.TransientModel): new_attach_id = ir_attachment_obj.copy(cr, uid, attach_id, {'res_model': self._name, 'res_id': wizard.id}, context=context) attachment_ids.append(new_attach_id) post_values['attachment_ids'] = attachment_ids - post_values.update(email_dict) # email_from: mass mailing only can specify another email_from if email_dict.get('email_from'): post_values['email_from'] = email_dict.pop('email_from') # replies redirection: mass mailing only if not wizard.same_thread: post_values['reply_to'] = email_dict.pop('reply_to') + else: + email_dict.pop('reply_to') + post_values.update(email_dict) # clean the context (hint: mass mailing sets some default values that # could be wrongly interpreted by mail_mail) context.pop('default_email_to', None) @@ -280,11 +296,10 @@ class mail_compose_message(osv.TransientModel): elif mass_mail_mode: # mass mail: is a log pushed to recipients unless specified, author not added if not wizard.notify: subtype = False - context = dict(context, mail_create_nosubscribe=True) # add context key to avoid subscribing the author - msg_id = active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **post_values) - # mass_mailing, post without notify: notify specific partners - if mass_mail_mode and not wizard.notify and post_values['partner_ids']: - self.pool.get('mail.notification')._notify(cr, uid, msg_id, post_values['partner_ids'], context=context) + context = dict(context, + mail_notify_force_send=False, # do not send emails directly but use the queue instead + mail_create_nosubscribe=True) # add context key to avoid subscribing the author + active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **post_values) return {'type': 'ir.actions.act_window_close'} |
