diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 99f6f187428..4e35f3fd197 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -208,10 +208,11 @@ class mail_thread(osv.Model): # mail.message wrappers and tools #------------------------------------------------------ - def _needaction_domain_get(self, cr, uid, context={}): + def _needaction_domain_get(self, cr, uid, context=None): if self._needaction: return [('message_unread', '=', True)] return [] + #------------------------------------------------------ # Mail gateway #------------------------------------------------------ diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index f7f9e2e8a3e..fa30c76aa1e 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -326,6 +326,7 @@ class test_mail(common.TransactionCase): # Mail data _subject = 'Pigs' + _subject_reply = 'Re: Pigs' _mail_subject = '%s posted on %s' % (user_admin.name, group_pigs.name) _body_text = 'Pigs rules' _msg_body1 = '
Pigs rules' @@ -373,22 +374,27 @@ class test_mail(common.TransactionCase): self.assertEqual(len(notif_ids), 4, 'mail.message: too much notifications created') self.assertEqual(set(msg_pids), set(test_pids), 'mail.message partner_ids incorrect') - # CASE2: reply to last comment with attachments + # CASE2: reply to last comment (update its subject) with attachments + message.write({'subject': _subject}) compose_id = mail_compose.create(cr, uid, {'attachment_ids': [(0, 0, _attachments[0]), (0, 0, _attachments[1])]}, {'mail.compose.message.mode': 'reply', 'default_model': 'mail.thread', 'default_res_id': self.group_pigs_id, 'active_id': message.id}) compose = mail_compose.browse(cr, uid, compose_id) # Test: form view methods - # Test: model, res_id, parent_id + # Test: model, res_id, parent_id, content_subtype self.assertEqual(compose.model, 'mail.group', 'mail.compose.message incorrect model') self.assertEqual(compose.res_id, self.group_pigs_id, 'mail.compose.message incorrect res_id') self.assertEqual(compose.parent_id.id, message.id, 'mail.compose.message incorrect parent_id') + self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message incorrect content_subtype') # Post the comment, get created message mail_compose.send_mail(cr, uid, [compose_id]) group_pigs.refresh() message = group_pigs.message_ids[0] + # Test: subject as Re:.., body in html + self.assertEqual(message.subject, _subject_reply, 'mail.message incorrect subject') + self.assertIn('Administrator wrote:
', message.body, 'mail.message body is incorrect') # Test: attachments for i in range(len(message.attachment_ids)): self.assertEqual(message.attachment_ids[i].name, _attachments[i]['name'], 'mail.message attachment name incorrect') @@ -406,13 +412,13 @@ class test_mail(common.TransactionCase): # Post the comment, get created message mail_compose.send_mail(cr, uid, [compose_id], {'default_res_id': -1, 'active_ids': [self.group_pigs_id]}) group_pigs.refresh() - msg = group_pigs.message_ids[0] + message = group_pigs.message_ids[0] # Test: last message on Pigs = last created message test_msg = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [], limit=1))[0] - self.assertEqual(msg.id, test_msg.id, 'Pigs did not receive its mass mailing message') + self.assertEqual(message.id, test_msg.id, 'Pigs did not receive its mass mailing message') # Test: mail.message: subject, body - self.assertEqual(msg.subject, _subject, 'mail.message subject is incorrect') - self.assertEqual(msg.body, group_pigs.description, 'mail.message body is incorrect') + self.assertEqual(message.subject, _subject, 'mail.message subject is incorrect') + self.assertEqual(message.body, group_pigs.description, 'mail.message body is incorrect') def test_30_message_read(self): """ Tests designed for message_read. """ diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 8698af42110..d141b3cf1e0 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -72,12 +72,12 @@ class mail_compose_message(osv.TransientModel): composition_mode = context.get('default_composition_mode', context.get('mail.compose.message.mode')) model = context.get('default_model', context.get('active_model')) res_id = context.get('default_res_id', context.get('active_id')) - active_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') # get default values according to the composition mode if composition_mode == 'reply': - vals = self.get_message_data(cr, uid, active_id, context=context) + vals = self.get_message_data(cr, uid, message_id, context=context) elif composition_mode == 'comment' and model and res_id: vals = self.get_record_data(cr, uid, model, res_id, context=context) elif composition_mode == 'mass_mail' and model and active_ids: @@ -155,7 +155,7 @@ class mail_compose_message(osv.TransientModel): message_data = self.pool.get('mail.message').browse(cr, uid, message_id, context=context) # create subject - re_prefix = _("Re:") + re_prefix = _('Re:') reply_subject = tools.ustr(message_data.subject or '') if not (reply_subject.startswith('Re:') or reply_subject.startswith(re_prefix)): reply_subject = "%s %s" % (re_prefix, reply_subject) @@ -163,7 +163,7 @@ class mail_compose_message(osv.TransientModel): reply_header = _('On %(date)s, %(sender_name)s wrote:') % { 'date': message_data.date if message_data.date else '', 'sender_name': message_data.author_id.name } - reply_body = 'Pigs rules
%s
%s