Skip to content

Port 18 cc bcc exactly once - #367

Closed
tdetry wants to merge 2 commits into
OCA:18.0from
GumbysBE:port-18-cc-bcc-exactly-once
Closed

tdetry wants to merge 2 commits into
OCA:18.0from
GumbysBE:port-18-cc-bcc-exactly-once

Conversation

@tdetry

@tdetry tdetry commented Nov 23, 2026

Copy link
Copy Markdown

No description provided.

Yannick Olivier and others added 2 commits October 2, 2026 11:30
Port to 18.0 of 3580f9c (19.0), superseding the context-based
composer_recipient_ids handling of 74d4358.

The Cc / Bcc are now read from the message itself (recipient_cc_ids /
recipient_bcc_ids), never from the context. mail.message gets a single
_get_cc_bcc_audience() splitting the audience in To, Cc and hidden Bcc
(a partner in To and Cc / Bcc stays To). Every copy shows the same To
and Cc headers; Bcc partners and followers reach only their own copy
through a Bcc header that Odoo strips before sending.

Fixed:
- a Cc made one copy too many
- with several Bcc only the last one was delivered, X-Odoo-Bcc is gone
- Cc recipients got the email once per language
- a recipient without email made the whole email fail
- a partner in To and Cc got two emails / an empty To
- emails sent by the queue or Retry lost the Cc / Bcc handling
- Cc / Bcc leaked to other messages posted in the same transaction
- internal followers showed in the customer's To and lost the View
  button: notification groups are no longer merged
- template emails posted by Odoo (order confirmation) now get the
  template Cc / Bcc, also with Default Recipients
- with a company default Cc the template Cc was ignored (default_get
  override removed, defaults come from the compute)
- switching template kept the Cc of the previous one
- with Default Recipients the composer overwrote a To chosen by the user
- replying from the full composer crashed (parent_id.partner_cc_ids)
- a logged note was emailed to the company default Cc / Bcc

Also:
- explicit Cc / Bcc always get an email, even internal users handling
  notifications in Odoo
- company default Cc / Bcc only apply to emails a user writes
- messages without Cc / Bcc cost no extra query

Adapted to Odoo 18:
- _notify_by_email_get_base_mail_values has no recipients_data on 18:
  _notify_thread_by_email sets a call-scoped context flag when a
  recipient is a Cc / Bcc, so other messages are not read
- no X-Msg-To-Add (Reply-All) header on 18: nothing to strip
- no allow_suggested in _generate_template_for_composer on 18: the
  Default Recipients To comes from Odoo's default recipients
- _notify_get_recipients keeps 18's positional msg_vals,
  _prepare_outgoing_list keeps recipients_follower_status
- tests: test_mail_cc_bcc_delivery.py ported (employee made partner
  manager as on 19.0 MailCommon, process_email_queue(ids=...),
  19.0-only header assertions adapted); existing tests updated to the
  new behaviour, assertions only (no merged notification groups,
  template Cc replaces the company default, followers hidden)
- kept minimal: README / readme fragments and manifest header untouched,
  only the version is bumped

Kept identical to 3580f9c: mail.message._get_cc_bcc_audience, the
composer Cc / Bcc compute and _prepare_mail_values_rendered, and the
_prepare_outgoing_list logic. Removed as on 19.0: default_get,
_notify_get_recipients_classify, _notify_thread, _action_send_mail_comment,
_expose_bcc_marker / X-Odoo-Bcc, the composer_recipient_ids context.
482ec1e (19.0 follow-up) is not part of this port.

Checks (Odoo 18.0 community, origin/18.0 d89bac4b):
- module tests: -i mail_composer_cc_bcc --test-enable
  --test-tags /mail_composer_cc_bcc -> 0 failed, 0 errors of 57 tests
- with sale + account installed, Odoo's own tests still pass:
  /account:TestAccountMoveSend, /account:TestAccountComposerPerformance,
  /sale:TestSaleOrder, /sale:TestSaleOrderCancel, /mail:TestMailComposer,
  /mail:TestMailComposerForm, /mail:TestMailComposerRendering plus the
  module -> 0 failed, 0 errors of 125 tests
- real SMTP (local SMTP server, no mocks), each recipient exactly one
  delivery, same To / Cc on every copy, no Bcc / X-Odoo-Bcc transmitted,
  Bcc and followers never in another copy: To + 2 Cc + 2 Bcc with
  uppercase addresses, mixed languages, internal user in Bcc, follower,
  partner in To and Cc, mail queue, Retry after SMTP failure, template
  notification, quotation "Send by email" (template + manual Cc / Bcc),
  order confirmation with template Cc / Bcc; message without Cc / Bcc
  keeps Odoo's headers. The same scenarios fail on 74d4358.
- pre-commit ruff, ruff-format, pylint-odoo: clean. The pinned
  oca-gen-addon-readme hook rewrites README.rst / index.html even on the
  untouched 18.0 files (banner, badge text): pre-existing, left as is

Known limits, unchanged by this port (same on 19.0):
- Resend from the failure popup (mail.resend.message) delivers once to
  each recipient without leaking the Bcc, but with Odoo's default
  per-recipient To and no Cc header
- invoices use account.move.send.wizard: the template Cc goes to To and
  the template Bcc is not sent, as in standard Odoo

Co-authored-by: Daan Marchal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-authored-by: omnigent <[email protected]>
@oca-cla-bot

oca-cla-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @trisdoan,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:18.0 mod:mail_composer_cc_bcc Module mail_composer_cc_bcc labels Nov 23, 2026
@tdetry tdetry closed this Nov 23, 2026
@tdetry
tdetry deleted the port-18-cc-bcc-exactly-once branch November 23, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:mail_composer_cc_bcc Module mail_composer_cc_bcc series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants