diff --git a/addons/crm/tests/test_crm_lead_lost.py b/addons/crm/tests/test_crm_lead_lost.py index e7dd92669fc..33d5f38ea41 100644 --- a/addons/crm/tests/test_crm_lead_lost.py +++ b/addons/crm/tests/test_crm_lead_lost.py @@ -92,7 +92,7 @@ class TestLeadConvert(crm_common.TestCrmCommon): self.assertEqual(lead.probability, 0) self.assertEqual(lead.lost_reason_id, self.lost_reason) # check messages - self.assertEqual(len(lead.message_ids), 3, 'Should have 3 messages: creation, lost, and log') + self.assertEqual(len(lead.message_ids), 2, 'Should have 2 messages: creation, lost with log') lost_message = lead.message_ids.filtered(lambda msg: msg.subtype_id == self.env.ref('crm.mt_lead_lost')) self.assertTrue(lost_message) self.assertTracking( @@ -101,9 +101,8 @@ class TestLeadConvert(crm_common.TestCrmCommon): ('lost_reason_id', 'many2one', False, self.lost_reason) ] ) - note_message = lead.message_ids.filtered(lambda msg: msg.subtype_id == self.env.ref('mail.mt_note')) - self.assertTrue(note_message) - self.assertEqual(note_message.body, '

I cannot find it. It was in my closet and pouf, disappeared.

') + self.assertIn('

I cannot find it. It was in my closet and pouf, disappeared.

', lost_message.body, + 'Feedback should be included directly within tracking message') @users('user_sales_salesman') @mute_logger('odoo.addons.base.models') diff --git a/addons/crm/wizard/crm_lead_lost.py b/addons/crm/wizard/crm_lead_lost.py index 66b36754c6f..0db92f5a739 100644 --- a/addons/crm/wizard/crm_lead_lost.py +++ b/addons/crm/wizard/crm_lead_lost.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import fields, models, _ from odoo.tools.mail import is_html_empty @@ -18,12 +18,12 @@ class CrmLeadLost(models.TransientModel): def action_lost_reason_apply(self): self.ensure_one() leads = self.env['crm.lead'].browse(self.env.context.get('active_ids')) - res = leads.action_set_lost(lost_reason_id=self.lost_reason_id.id) if not is_html_empty(self.lost_feedback): - leads._message_log_batch( - bodies=dict( - (lead.id, self.lost_feedback) - for lead in leads), - subject=False, + leads._track_set_log_message( + '

%s:

%s
' % ( + _('Lost Comment'), + self.lost_feedback + ) ) + res = leads.action_set_lost(lost_reason_id=self.lost_reason_id.id) return res diff --git a/addons/crm/wizard/crm_lead_lost_views.xml b/addons/crm/wizard/crm_lead_lost_views.xml index c6ca6b23aca..b046443d5e8 100644 --- a/addons/crm/wizard/crm_lead_lost_views.xml +++ b/addons/crm/wizard/crm_lead_lost_views.xml @@ -5,10 +5,10 @@ crm.lead.lost
- + - +