[FIX] mail_tracking: Store cc

This commit is contained in:
Alexandre D. Díaz 2021-03-01 23:00:26 +01:00 committed by Jasmin Solanki
parent b8f28055eb
commit bb633d22c5
2 changed files with 10 additions and 7 deletions

View File

@ -29,17 +29,20 @@ class MailThread(models.AbstractModel):
("mail_tracking_ids.state", "in", list(failed_states)),
]
@api.returns("self", lambda value: value.id)
def message_post(self, *args, **kwargs):
@api.model
def _message_route_process(self, message, message_dict, routes):
"""Adds CC recipient to the message.
Because Odoo implementation avoid store 'from, to, cc' recipients we
ensure that this information its written into the mail.message record.
"""
kwargs.update(
{"email_cc": kwargs.get("cc", False), "email_to": kwargs.get("to", False)}
message_dict.update(
{
"email_cc": message_dict.get("cc", False),
"email_to": message_dict.get("to", False),
}
)
return super().message_post(*args, **kwargs)
return super()._message_route_process(message, message_dict, routes)
def _message_get_suggested_recipients(self):
"""Adds email 'extra' recipients as suggested recipients.

View File

@ -182,7 +182,7 @@ class TestMailTracking(TransactionCase):
# pylint: disable=C8107
message = self.recipient.with_user(sender_user).message_post(
body="<p>This is a test message</p>",
cc="Dominique Pinon <unnamed@test.com>, sender@example.com",
email_cc="Dominique Pinon <unnamed@test.com>, sender@example.com",
)
# suggested recipients
recipients = self.recipient._message_get_suggested_recipients()
@ -235,7 +235,7 @@ class TestMailTracking(TransactionCase):
# pylint: disable=C8107
message = self.recipient.with_user(sender_user).message_post(
body="<p>This is a test message</p>",
to="Dominique Pinon <support+unnamed@test.com>, sender@example.com",
email_to="Dominique Pinon <support+unnamed@test.com>, sender@example.com",
)
# suggested recipients
recipients = self.recipient._message_get_suggested_recipients()