Skip to content

[18.0][MIG] mail_visible_email#214

Open
ntsirintanis wants to merge 3 commits into
OCA:18.0from
Therp:18.0-mig-mail-mail_visible_email
Open

[18.0][MIG] mail_visible_email#214
ntsirintanis wants to merge 3 commits into
OCA:18.0from
Therp:18.0-mig-mail-mail_visible_email

Conversation

@ntsirintanis

Copy link
Copy Markdown

forwardport of OCA/social#1643

NL66278 and others added 2 commits June 23, 2026 15:16
This module will show actual to, cc and bcc headers used on
incoming and outgoing mails.
@OCA-git-bot OCA-git-bot added series:18.0 mod:mail_visible_email Module mail_visible_email labels Jun 23, 2026
- The module mail_composer_bcc fundamentally changes the workings of the
\_send() method on mail.mail. In order not to have to support both
methods depending on whether mail_composer_bcc is installed or not, it
is easier to just make sure it is installed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right so yes in 18.0 this isn't true anymore, yet, that also thwarts the reason to not have a regular module and a glue module for the bcc addition.

Comment thread mail_visible_email/models/mail_mail.py Outdated
existing = message[fieldname]
if existing:
emails += existing.split(",")
return ",".join(list(set(emails)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These abstractions make sense to me, why lose them upon migration?

Comment thread mail_visible_email/models/mail_mail.py Outdated
for mail in self.filtered(lambda r: r.state == "outgoing"):
vals = {}
for fname in ("email_to", "email_cc", "email_bcc"):
raw = mail[fname]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering if here, before super is called, these fields already all have their right values.

Because it seems like for example email_bcc is only filled upon calling _prepare_outgoing_list, which is part of super._send().

If it isn't, we can of course ourselves do what mail_composer_cc_bcc does to fill the fields:

        partners_cc_bcc = self.recipient_cc_ids + self.recipient_bcc_ids
        partner_to_ids = [r.id for r in self.recipient_ids if r not in partners_cc_bcc]
        partner_to = self.env["res.partner"].browse(partner_to_ids)
        email_to = format_emails(partner_to)
        email_cc = format_emails_str(self.recipient_cc_ids)
        email_bcc = [r.email for r in self.recipient_bcc_ids if r.email]

Or already sneakily call prepare_outgoing_list once to get the values, but then we'd have to mind the context change that the function does

Comment thread mail_visible_email/models/mail_mail.py Outdated

def _send(
self,
auto_commit=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should take the opportunity of the migration to replace all the keyword arguments with **kwargs as none of these arguments is referenced in the overriding method and they are passed unchanged.

@NL66278 NL66278 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good, one suggestion for an improvement on the original.

@ntsirintanis ntsirintanis force-pushed the 18.0-mig-mail-mail_visible_email branch 3 times, most recently from 5f96b45 to 976b8b5 Compare June 24, 2026 08:14

@tarteo tarteo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I can test this easily. I created a email template with cc and bcc, when I then send a email using the template it will not show up as in the CC and BCC field.

My mailing template:

Image The message record: Image The email record: Image

@thomaspaulb

Copy link
Copy Markdown

@tarteo At least for the BCC field, it's added to the mail.mail record only upon actual sending, which calls _prepare_outgoing_list not yet when the mail is created in Outgoing state. It also triggers on mails sent via composer only, any value on the templates is not taken into account AFAIK.

How did you get the mail to send without an outgoing mail server?

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@ntsirintanis ntsirintanis force-pushed the 18.0-mig-mail-mail_visible_email branch from 976b8b5 to 30b5896 Compare July 2, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants