Skip to content

Commit

Permalink
Merge PR #1223 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by etobella
  • Loading branch information
OCA-git-bot committed Oct 9, 2023
2 parents 0084ea1 + 57120ad commit 059c7d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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 @@ -44,8 +44,8 @@ def _send( # noqa: max-complexity: 4
success_pids = []
failure_type = None
# ===== Same with native Odoo =====
# https://github.com/odoo/odoo/blob/6ec4ba7ba22626219ddd09241c274b09a21fac0b
# /addons/mail/models/mail_mail.py#L375
# https://github.com/odoo/odoo/blob/0a3fc96cd51c0aab024207a4608f6ba32d49da36
# /addons/mail/models/mail_mail.py#L384
try:
if mail.state != "outgoing":
if mail.state != "exception" and mail.auto_delete:
Expand Down Expand Up @@ -125,11 +125,16 @@ def _send( # noqa: max-complexity: 4
records=notifs,
)

# 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)
email_from = emails_from[0] if emails_from else mail.email_from

# build an RFC2822 email.message.Message object and send it without queuing
res = None
# 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 =====
email["email_from"] = email_from
msg = self.build_email(
email,
attachments=attachments,
Expand Down Expand Up @@ -230,12 +235,13 @@ def _send( # noqa: max-complexity: 4
def build_email(self, email, attachments=None, headers=None):
env = self.env
mail = self
email_from = email.get("email_from")
IrMailServer = env["ir.mail_server"]
# ===== Same with native Odoo =====
# https://github.com/odoo/odoo/blob/6ec4ba7ba22626219ddd09241c274b09a21fac0b
# /addons/mail/models/mail_mail.py#L447
# https://github.com/odoo/odoo/blob/0a3fc96cd51c0aab024207a4608f6ba32d49da36
# /addons/mail/models/mail_mail.py#L458
msg = IrMailServer.build_email(
email_from=mail.email_from,
email_from=email_from,
email_to=email.get("email_to"),
subject=mail.subject,
body=email.get("body"),
Expand Down
2 changes: 1 addition & 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,7 @@
from odoo.addons.mail.models.mail_mail import MailMail as upstream
from odoo.addons.mail.tests.test_mail_composer import TestMailComposer

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


class TestMailCcBcc(TestMailComposer):
Expand Down

0 comments on commit 059c7d2

Please sign in to comment.