From 4b00548e749c73d83968e914f0f125edb58fcc8f Mon Sep 17 00:00:00 2001 From: roen-odoo <roen@odoo.com> Date: Fri, 10 Dec 2021 10:52:54 +0000 Subject: [PATCH] [FIX] mail : Remove double signature on invoice email Current behavior : When sending an invoice by email there was 2 signature in the mail Steps to reproduce : Create an invoice Send it by email Check the mail, there are 2 signatures opw-2703272 closes odoo/odoo#81086 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> --- addons/mail/data/mail_data.xml | 2 +- addons/test_mail/models/test_mail_models.py | 5 +++++ addons/test_mail/tests/test_message_post.py | 25 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 6b5b6298acae..0963ef3dc5b5 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -269,7 +269,7 @@ <t t-esc="access_name"/> </a> </div> - <t t-if="record.user_id and not record.env.user._is_superuser()"> + <t t-if="record.user_id and not record.env.user._is_superuser() and signature != ''"> <div style="margin: 0px; padding: 0px; font-size:13px;"> Best regards, </div> diff --git a/addons/test_mail/models/test_mail_models.py b/addons/test_mail/models/test_mail_models.py index 76fc0921bcea..f9cff37db93f 100644 --- a/addons/test_mail/models/test_mail_models.py +++ b/addons/test_mail/models/test_mail_models.py @@ -41,6 +41,11 @@ class MailTestStandard(models.Model): container_id = fields.Many2one('mail.test.container', tracking=True) company_id = fields.Many2one('res.company') + def _get_share_url(self, redirect, signup_partner, share_token): + """This function is required for a test on 'mail.mail_notification_paynow' template (test_message_post/test_mail_add_signature), + another model should be created in master""" + return '/mail/view' + class MailTestActivity(models.Model): """ This model can be used to test activities in addition to simple chatter diff --git a/addons/test_mail/tests/test_message_post.py b/addons/test_mail/tests/test_message_post.py index da961a5c4bb0..54db9ce13f09 100644 --- a/addons/test_mail/tests/test_message_post.py +++ b/addons/test_mail/tests/test_message_post.py @@ -36,6 +36,31 @@ class TestMessagePost(TestMailCommon, TestRecipients): messageId = call_kw(self.env['mail.channel'], 'message_post', [test_channel.id], {'body': 'test'}) self.assertTrue(isinstance(messageId, int)) + @users('employee') + def test_notify_mail_add_signature(self): + self.test_track = self.env['mail.test.track'].with_context(self._test_context).with_user(self.user_employee).create({ + 'name': 'Test', + 'email_from': 'ignasse@example.com' + }) + self.test_track.user_id = self.env.user + + signature = self.env.user.signature + + template = self.env.ref('mail.mail_notification_paynow', raise_if_not_found=True).sudo() + self.assertIn("record.user_id.sudo().signature", template.arch) + + with self.mock_mail_gateway(): + self.test_track.message_post(body="Test body", mail_auto_delete=False, add_sign=True, partner_ids=[self.partner_1.id, self.partner_2.id], email_layout_xmlid="mail.mail_notification_paynow") + found_mail = self._new_mails + self.assertIn(signature, found_mail.body_html) + self.assertEqual(found_mail.body_html.count(signature), 1) + + with self.mock_mail_gateway(): + self.test_track.message_post(body="Test body", mail_auto_delete=False, add_sign=False, partner_ids=[self.partner_1.id, self.partner_2.id], email_layout_xmlid="mail.mail_notification_paynow") + found_mail = self._new_mails + self.assertNotIn(signature, found_mail.body_html) + self.assertEqual(found_mail.body_html.count(signature), 0) + @users('employee') def test_notify_prepare_template_context_company_value(self): """ Verify that the template context company value is right -- GitLab