From 376ad8dab6afdf210ab1b98977b14da96db17767 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 12 Dec 2024 12:38:53 +0100 Subject: [PATCH 1/3] [FIX] mail_composer_cc_bcc: adapt to changes upstream --- mail_composer_cc_bcc/models/mail_mail.py | 14 ++++++++++---- mail_composer_cc_bcc/tests/test_mail_cc_bcc.py | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mail_composer_cc_bcc/models/mail_mail.py b/mail_composer_cc_bcc/models/mail_mail.py index e01ac8a0df..29e906780b 100644 --- a/mail_composer_cc_bcc/models/mail_mail.py +++ b/mail_composer_cc_bcc/models/mail_mail.py @@ -18,7 +18,13 @@ def format_emails(partners): emails = [ - tools.formataddr((p.name or "False", p.email or "False")) for p in partners + tools.formataddr( + ( + p.name or "False", + p.email and tools.mail._normalize_email(p.email) or "False", + ) + ) + for p in partners ] return ", ".join(emails) @@ -48,8 +54,8 @@ def _send( # noqa: max-complexity: 4 success_pids = [] failure_type = None # ===== Same with native Odoo ===== - # https://github.com/odoo/odoo/blob/1098b033b4e1811d6ff4b8c3b90aa6b9e697cb93 - # /addons/mail/models/mail_mail.py#L465 + # https://github.com/odoo/odoo/blob/2baa481e14ca705f4c6d3d4d900daf24442a4aa5 + # /addons/mail/models/mail_mail.py#L463 try: if mail.state != "outgoing": if mail.state != "exception" and mail.auto_delete: @@ -129,7 +135,7 @@ def _send( # noqa: max-complexity: 4 ) # protect against ill-formatted email_from when formataddr was used on an already formatted email # noqa: B950 - emails_from = tools.email_split_and_format(mail.email_from) + emails_from = tools.email_split_and_format_normalize(mail.email_from) email_from = emails_from[0] if emails_from else mail.email_from # build an RFC2822 email.message.Message object and send it without queuing diff --git a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py index d8ebefcfe2..36bf2005cd 100644 --- a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py +++ b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py @@ -14,6 +14,7 @@ "d52cb36b88b33abc9556f7be6718d93f", "461467cd5b356072fc054468c75f6e26", "5d1ab352416f5074e131f35f20098d5b", + "46172c91183f2cb50b22a6b3b5e3869b", ] From 5d8a39c156531926a6c82cecc8d967fa64675bd7 Mon Sep 17 00:00:00 2001 From: trisdoan Date: Mon, 16 Dec 2024 09:55:27 +0700 Subject: [PATCH 2/3] [FIX] mail_composer_cc_bcc: adapt to changes from upstream --- mail_composer_cc_bcc/README.rst | 1 + mail_composer_cc_bcc/models/mail_mail.py | 4 ++-- mail_composer_cc_bcc/readme/CONTRIBUTORS.rst | 1 + mail_composer_cc_bcc/static/description/index.html | 1 + mail_composer_cc_bcc/tests/test_mail_cc_bcc.py | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mail_composer_cc_bcc/README.rst b/mail_composer_cc_bcc/README.rst index 5c8fef9206..e2cc9508b0 100644 --- a/mail_composer_cc_bcc/README.rst +++ b/mail_composer_cc_bcc/README.rst @@ -106,6 +106,7 @@ Contributors * Hai N. Le * Son Ho + * Tris Doan * `Therp BV `_: diff --git a/mail_composer_cc_bcc/models/mail_mail.py b/mail_composer_cc_bcc/models/mail_mail.py index 29e906780b..29ab4d6e3f 100644 --- a/mail_composer_cc_bcc/models/mail_mail.py +++ b/mail_composer_cc_bcc/models/mail_mail.py @@ -54,7 +54,7 @@ def _send( # noqa: max-complexity: 4 success_pids = [] failure_type = None # ===== Same with native Odoo ===== - # https://github.com/odoo/odoo/blob/2baa481e14ca705f4c6d3d4d900daf24442a4aa5 + # https://github.com/odoo/odoo/blob/55c165dc8777514afa4f1476b82ef6b50b8a7651 # /addons/mail/models/mail_mail.py#L463 try: if mail.state != "outgoing": @@ -81,7 +81,7 @@ def _send( # noqa: max-complexity: 4 email = mail._send_prepare_values() # ===== Same with native Odoo ===== # headers - headers = {} + headers = {"X-Odoo-Message-Id": mail.message_id} bounce_alias = ICP.get_param("mail.bounce.alias") catchall_domain = ICP.get_param("mail.catchall.domain") if bounce_alias and catchall_domain: diff --git a/mail_composer_cc_bcc/readme/CONTRIBUTORS.rst b/mail_composer_cc_bcc/readme/CONTRIBUTORS.rst index 707d8e429d..bd3e5b1bfb 100644 --- a/mail_composer_cc_bcc/readme/CONTRIBUTORS.rst +++ b/mail_composer_cc_bcc/readme/CONTRIBUTORS.rst @@ -2,6 +2,7 @@ * Hai N. Le * Son Ho + * Tris Doan * `Therp BV `_: diff --git a/mail_composer_cc_bcc/static/description/index.html b/mail_composer_cc_bcc/static/description/index.html index 2bc3f0a903..48b16cbb4e 100644 --- a/mail_composer_cc_bcc/static/description/index.html +++ b/mail_composer_cc_bcc/static/description/index.html @@ -452,6 +452,7 @@

Contributors

diff --git a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py index 36bf2005cd..90f0d6d254 100644 --- a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py +++ b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py @@ -15,6 +15,7 @@ "461467cd5b356072fc054468c75f6e26", "5d1ab352416f5074e131f35f20098d5b", "46172c91183f2cb50b22a6b3b5e3869b", + "8f26c4084cc7fc300e64d19ccdc944fe", ] From 35e89eb77bc18387255f544cb95f2dc784149dfa Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 16 Dec 2024 10:44:37 +0100 Subject: [PATCH 3/3] [ADD] mail_composer_cc_bcc: more helpful error message for test This is a test that compares the hash of the source code of a function they override with a list of known hashes, so as soon as this changes in upstream, the test fails and we know we have to check if we need to incorporate any changes from there. --- mail_composer_cc_bcc/tests/test_mail_cc_bcc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py index 90f0d6d254..fb0751cc03 100644 --- a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py +++ b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py @@ -48,7 +48,12 @@ def test_upstream_file_hash(self): """Test that copied upstream function hasn't received fixes""" func = inspect.getsource(upstream._send).encode() func_hash = hashlib.md5(func).hexdigest() - self.assertIn(func_hash, VALID_HASHES) + self.assertIn( + func_hash, + VALID_HASHES, + "mail.mail#_send has changed in upstream, " + "please adapt the override and add the new hash above", + ) def test_email_cc_bcc(self): form = self.open_mail_composer_form()