From 7f0353974d7ee825d8cd63c9968e8e93c93b4888 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Aug 2014 13:02:42 +0200 Subject: [PATCH] [REF] mail: same_thread field changed into no_auto_thread, its contrary, to avoid migration issues (adding a 'always False' column is easier than an 'always True'). --- addons/hr_recruitment/hr_recruitment.py | 1 - addons/mail/mail_message.py | 7 +++---- addons/mail/tests/test_mail_message.py | 2 +- addons/mail/wizard/mail_compose_message.py | 6 +++--- addons/mail/wizard/mail_compose_message_view.xml | 6 +++--- addons/mass_mailing/models/mass_mailing.py | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 4908532..9fe72cc 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -453,7 +453,6 @@ class hr_applicant(osv.Model): 'model': self._name, 'composition_mode': 'mass_mail', 'template_id': stage.template_id.id, - 'same_thread': True, 'post': True, 'notify': True, }, context=compose_ctx) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index b545770..8109e34 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -130,8 +130,8 @@ class mail_message(osv.Model): help="Email address of the sender. This field is set when no matching partner is found for incoming emails."), 'reply_to': fields.char('Reply-To', help='Reply email address. Setting the reply_to bypasses the automatic thread creation.'), - 'same_thread': fields.boolean('Same thread', - help='Redirect answers to the same discussion thread.'), + 'no_auto_thread': fields.boolean('No threading for answers', + help='Answers do not go in the original document\' discussion thread. This has an impact on the generated message-id.'), 'author_id': fields.many2one('res.partner', 'Author', select=1, ondelete='set null', help="Author of the message. If not set, email_from may hold an email address that did not match any partner."), @@ -189,7 +189,6 @@ class mail_message(osv.Model): 'author_id': lambda self, cr, uid, ctx=None: self._get_default_author(cr, uid, ctx), 'body': '', 'email_from': lambda self, cr, uid, ctx=None: self._get_default_from(cr, uid, ctx), - 'same_thread': True, } #------------------------------------------------------ @@ -777,7 +776,7 @@ class mail_message(osv.Model): return self.pool['mail.thread'].message_get_reply_to(cr, uid, [res_id], default=email_from, context=ctx)[res_id] def _get_message_id(self, cr, uid, values, context=None): - if values.get('same_thread', True) is False: + if values.get('no_auto_thread', False) is True: message_id = tools.generate_tracking_message_id('reply_to') elif values.get('res_id') and values.get('model'): message_id = tools.generate_tracking_message_id('%(res_id)s-%(model)s' % values) diff --git a/addons/mail/tests/test_mail_message.py b/addons/mail/tests/test_mail_message.py index 40d6786..7bbc9aa 100644 --- a/addons/mail/tests/test_mail_message.py +++ b/addons/mail/tests/test_mail_message.py @@ -90,7 +90,7 @@ class TestMailMessage(TestMail): self.registry('ir.config_parameter').unlink(cr, uid, param_ids) # Do: free message; specified values > default values - msg_id = self.mail_message.create(cr, user_raoul_id, {'same_thread': False, 'reply_to': reply_to1, 'email_from': email_from1}) + msg_id = self.mail_message.create(cr, user_raoul_id, {'no_auto_thread': True, 'reply_to': reply_to1, 'email_from': email_from1}) msg = self.mail_message.browse(cr, user_raoul_id, msg_id) # Test: message content self.assertIn('reply_to', msg.message_id, diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 41dc4a9..66f843c 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -248,7 +248,7 @@ class mail_compose_message(osv.TransientModel): rendered_values = self.render_message_batch(cr, uid, wizard, res_ids, context=context) # compute alias-based reply-to in batch reply_to_value = dict.fromkeys(res_ids, None) - if mass_mail_mode and wizard.same_thread: + if mass_mail_mode and not wizard.no_auto_thread: reply_to_value = self.pool['mail.thread'].message_get_reply_to(cr, uid, res_ids, default=wizard.email_from, context=dict(context, thread_model=wizard.model)) for res_id in res_ids: @@ -274,11 +274,11 @@ class mail_compose_message(osv.TransientModel): email_dict = rendered_values[res_id] mail_values['partner_ids'] += email_dict.pop('partner_ids', []) mail_values.update(email_dict) - if wizard.same_thread: + if not wizard.no_auto_thread: mail_values.pop('reply_to') if reply_to_value.get(res_id): mail_values['reply_to'] = reply_to_value[res_id] - if not wizard.same_thread and not mail_values.get('reply_to'): + if wizard.no_auto_thread and not mail_values.get('reply_to'): mail_values['reply_to'] = mail_values['email_from'] # mail_mail values: body -> body_html, partner_ids -> recipient_ids mail_values['body_html'] = mail_values.get('body', '') diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml index 5d358e3..860e106 100644 --- a/addons/mail/wizard/mail_compose_message_view.xml +++ b/addons/mail/wizard/mail_compose_message_view.xml @@ -46,10 +46,10 @@ - + + attrs="{'invisible':['|', ('no_auto_thread', '=', False), ('composition_mode', '!=', 'mass_mail')], + 'required':[('no_auto_thread', '=', True), ('composition_mode', '=', 'mass_mail')]}"/> diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index ae1a334..b80aa43 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -601,7 +601,7 @@ class MassMailing(osv.Model): 'composition_mode': 'mass_mail', 'mass_mailing_id': mailing.id, 'mailing_list_ids': [(4, l.id) for l in mailing.contact_list_ids], - 'same_thread': mailing.reply_to_mode == 'thread', + 'no_auto_thread': mailing.reply_to_mode != 'thread', } if mailing.reply_to_mode == 'email': composer_values['reply_to'] = mailing.reply_to -- 1.7.10.4