diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 20eb2ad9b91..069e1b0d35a 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -409,12 +409,14 @@ class test_mail(common.TransactionCase): self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message incorrect content_subtype') # 2. Post the comment, get created message + parent_id = message.id mail_compose.send_mail(cr, uid, [compose_id]) group_pigs.refresh() message = group_pigs.message_ids[0] - # Test: mail.message: subject as Re:.., body in html + # Test: mail.message: subject as Re:.., body in html, parent_id self.assertEqual(message.subject, _msg_reply, 'mail.message incorrect subject') self.assertIn('Administrator wrote:
Pigs rules
', message.body, 'mail.message body is incorrect') + self.assertEqual(message.parent_id and message.parent_id.id, parent_id, 'mail.message parent_id incorrect') # Test: mail.message: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index ccb592755cc..03c5a7cfe8b 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -116,7 +116,7 @@ class mail_compose_message(osv.TransientModel): 'composition_mode': 'comment', 'content_subtype': lambda self, cr, uid, ctx={}: 'plain', 'body_text': lambda self, cr, uid, ctx={}: False, - 'body': lambda self, cr, uid, ctx={}: False, + 'body': lambda self, cr, uid, ctx={}: '', 'subject': lambda self, cr, uid, ctx={}: False, 'partner_ids': lambda self, cr, uid, ctx={}: [], } @@ -154,7 +154,7 @@ class mail_compose_message(osv.TransientModel): # create subject re_prefix = _('Re:') reply_subject = tools.ustr(message_data.subject or '') - if not (reply_subject.startswith('Re:') or reply_subject.startswith(re_prefix)): + if not (reply_subject.startswith('Re:') or reply_subject.startswith(re_prefix)) and message_data.subject: reply_subject = "%s %s" % (re_prefix, reply_subject) # create the reply in the body reply_body = _('
On %(date)s, %(sender_name)s wrote:
%(body)s
') % { @@ -250,6 +250,7 @@ class mail_compose_message(osv.TransientModel): post_values = { 'subject': wizard.subject if wizard.content_subtype == 'html' else False, 'body': wizard.body if wizard.content_subtype == 'html' else '
%s
' % tools.ustr(wizard.body_text), + 'parent_id': wizard.parent_id and wizard.parent_id.id, 'partner_ids': [(4, partner.id) for partner in wizard.partner_ids], 'attachments': [(attach.datas_fname or attach.name, base64.b64decode(attach.datas)) for attach in wizard.attachment_ids], }