From 9c57f6e1cdaf8a80a403486b51cd9e661c11e3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Jun 2013 12:24:37 +0200 Subject: [FIX] mail: various fixes Mass mailing: emails due to mass mailing are not queued instead of sent immediately. As most of cases go through mail_followers._notify(), a new argument is added that allows to control the force_send (like what is done in email_template). Chatter: better display of recipients when having a message_post due to mass mailing (not always displaying logged a note). Notified people: when having no subtype, just avoid notifying the followers but take into account specified recipients (partner_ids). bzr revid: tde@openerp.com-20130606102437-43s4xp96b5wa3r1q --- addons/mail/wizard/mail_compose_message.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 7bf4d47d1ff..383929a6e07 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -126,7 +126,6 @@ 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={}: [], @@ -158,7 +157,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): """ Override specific notify method of mail.message, because we do not want that feature in the wizard. """ return @@ -280,11 +279,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'} -- cgit v1.2.3 From a216e70e8513d1b9cad807b738023d8a92d8c8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Jun 2013 14:32:30 +0200 Subject: [FIX] [IMP] mail: allow to use message_post on models not having message_post method defined. mail.compose.message wizard and messaage_process now check that the active model has message_post defined. Otherwise using thread_model context key that is better managed in message_post, it is possible to use mail_thread.message_post() with a thread_model and thread_id that should not allow message_post otherwise. Hint: look for backport into 7.0 bzr revid: tde@openerp.com-20130606123230-d7ql14yydzfrlc7h --- addons/mail/wizard/mail_compose_message.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 383929a6e07..e3383270548 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -234,6 +234,9 @@ 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 res_ids = active_ids if mass_mail_mode and wizard.model and active_ids else [wizard.res_id] -- cgit v1.2.3 From 72f6a8c646179d433de11c2f26e5f589b5ad8cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Jun 2013 14:37:24 +0200 Subject: [FIX] mail.compose.message: supports user_signature of template. Note that in case of multiple wizards (send on ids that is not a singleton list), user_signature on one template is valid for all wizard. bzr revid: tde@openerp.com-20130606123724-f7q3mwm81ek7mr5c --- addons/mail/wizard/mail_compose_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index e3383270548..64886628478 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -157,7 +157,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, force_send=False): + 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 -- cgit v1.2.3 From a1e942c0dec4d016655f12031c9a78336b2d83d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Jun 2013 16:28:14 +0200 Subject: [FIX] mail.compose.message: fixed reply_to from template in mass mailing. bzr revid: tde@openerp.com-20130606142814-jyw76nhaeivotu6k --- addons/mail/wizard/mail_compose_message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 64886628478..7685a27f1ed 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -259,13 +259,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) -- cgit v1.2.3 From db0cd38559bc704527af856d516c5f61be391f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 22 Jul 2013 13:23:06 +0200 Subject: [IMP] mail.compose.message: now proposes to work on active_domain bzr revid: tde@openerp.com-20130722112306-r1u77tyqzk4bknrb --- addons/mail/wizard/mail_compose_message.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 7685a27f1ed..02fac7f010f 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -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 = { -- cgit v1.2.3 From f1f2b2ba06c6b62c886b7dea13118687e9b93b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 22 Jul 2013 15:17:25 +0200 Subject: [IMP] mail: mail.message now has mail_server_id from template_id. bzr revid: tde@openerp.com-20130722131725-i30xd4b03nui3hyw --- addons/mail/wizard/mail_compose_message.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 02fac7f010f..95647e95d8e 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -130,6 +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={}: [], 'post': lambda self, cr, uid, ctx={}: True, 'same_thread': lambda self, cr, uid, ctx={}: True, -- cgit v1.2.3 From 91ef7de7090e92314abebe377f7eacd01b483000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 25 Jul 2013 15:50:29 +0200 Subject: [IMP] mail: better implementation of active domain / use active domain bzr revid: tde@openerp.com-20130725135029-mx946vaibvz1rzii --- addons/mail/wizard/mail_compose_message.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 95647e95d8e..432840d50ef 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -73,7 +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') - result['active_domain'] = '%s' % context.get('active_domain', []) + if context.get('active_domain'): + 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': -- cgit v1.2.3 From fa7fc1277b879e23381c276ef531940d50d681eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 26 Jul 2013 12:43:42 +0200 Subject: [FIX] mail_compose_message: keep empty domains bzr revid: tde@openerp.com-20130726104342-8o5s2k85d7sjuwoy --- addons/mail/wizard/mail_compose_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 432840d50ef..6ab1f0e81ff 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -73,7 +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') - if context.get('active_domain'): + 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: -- cgit v1.2.3