Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] mail_composer_cc_bcc: adapt to changes upstream #1519

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mail_composer_cc_bcc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Contributors

* Hai N. Le <hailn@trobz.com>
* Son Ho <sonhd@trobz.com>
* Tris Doan <tridm@trobz.com>

* `Therp BV <https://therp.nl>`_:

Expand Down
16 changes: 11 additions & 5 deletions mail_composer_cc_bcc/models/mail_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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/55c165dc8777514afa4f1476b82ef6b50b8a7651
# /addons/mail/models/mail_mail.py#L463
try:
if mail.state != "outgoing":
if mail.state != "exception" and mail.auto_delete:
Expand All @@ -75,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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions mail_composer_cc_bcc/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Hai N. Le <hailn@trobz.com>
* Son Ho <sonhd@trobz.com>
* Tris Doan <tridm@trobz.com>

* `Therp BV <https://therp.nl>`_:

Expand Down
1 change: 1 addition & 0 deletions mail_composer_cc_bcc/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ <h1>Contributors</h1>
<ul class="simple">
<li>Hai N. Le &lt;<a class="reference external" href="mailto:hailn&#64;trobz.com">hailn&#64;trobz.com</a>&gt;</li>
<li>Son Ho &lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li>
<li>Tris Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</blockquote>
</li>
Expand Down
9 changes: 8 additions & 1 deletion mail_composer_cc_bcc/tests/test_mail_cc_bcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"d52cb36b88b33abc9556f7be6718d93f",
"461467cd5b356072fc054468c75f6e26",
"5d1ab352416f5074e131f35f20098d5b",
"46172c91183f2cb50b22a6b3b5e3869b",
"8f26c4084cc7fc300e64d19ccdc944fe",
]


Expand Down Expand Up @@ -46,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()
Expand Down
Loading