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

[15.0][FIX] mail_composer_cc_bcc: adapt to changes upstream #1408

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
19 changes: 14 additions & 5 deletions mail_composer_cc_bcc/models/mail_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
success_pids = []
failure_type = None
# ===== Same with native Odoo =====
# https://github.com/odoo/odoo/blob/0a3fc96cd51c0aab024207a4608f6ba32d49da36
# /addons/mail/models/mail_mail.py#L384
# https://github.com/odoo/odoo/blob/28e1e01835c0df2ad6e9ddf131dd438fcf6072e1
# /addons/mail/models/mail_mail.py#L402
try:
if mail.state != "outgoing":
if mail.state != "exception" and mail.auto_delete:
Expand Down Expand Up @@ -135,11 +135,20 @@
# TDE note: could be great to pre-detect missing to/cc and skip sending it
# to go directly to failed state update
# ===== Different than native Odoo =====
# support headers specific to the specific outgoing email
if email.get("headers"):
email_headers = headers.copy()
try:
email_headers.update(email.get("headers"))
except Exception as e:
_logger.warning("Error during email_headers update: %s", e)

Check warning on line 144 in mail_composer_cc_bcc/models/mail_mail.py

View check run for this annotation

Codecov / codecov/patch

mail_composer_cc_bcc/models/mail_mail.py#L140-L144

Added lines #L140 - L144 were not covered by tests
else:
email_headers = headers
email["email_from"] = email_from
msg = self.build_email(
email,
attachments=attachments,
headers=headers,
headers=email_headers,
)
try:
res = IrMailServer.send_email(
Expand Down Expand Up @@ -239,8 +248,8 @@
email_from = email.get("email_from")
IrMailServer = env["ir.mail_server"]
# ===== Same with native Odoo =====
# https://github.com/odoo/odoo/blob/0a3fc96cd51c0aab024207a4608f6ba32d49da36
# /addons/mail/models/mail_mail.py#L458
# https://github.com/odoo/odoo/blob/28e1e01835c0df2ad6e9ddf131dd438fcf6072e1
# /addons/mail/models/mail_mail.py#L486
msg = IrMailServer.build_email(
email_from=email_from,
email_to=email.get("email_to"),
Expand Down
6 changes: 5 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 @@ -10,7 +10,11 @@
from odoo.addons.mail.models.mail_mail import MailMail as upstream
from odoo.addons.mail.tests.test_mail_composer import TestMailComposer

VALID_HASHES = ["5f8b9bd28ccfe4f4ef1702002b2ab3fc", "0e47779dfd6e70de1cc1457792c68c0f"]
VALID_HASHES = [
"5f8b9bd28ccfe4f4ef1702002b2ab3fc",
"0e47779dfd6e70de1cc1457792c68c0f",
"a918e6f4fc0577cda7680d026ac85278",
]


class TestMailCcBcc(TestMailComposer):
Expand Down
Loading