Repository navigation
feat: optional one-line subject for chatter_post - #76
Open
bitclicklabs wants to merge 1 commit into
Open
bitclicklabs wants to merge 1 commit into
bitclicklabs wants to merge 1 commit into
Conversation
Without a subject, Odoo titles the notification email of a chatter comment with the record name (for example "INV/2026/00036"), so callers that send customer-facing messages had to fall back to an allow-listed <model>.message_post instead of chatter_post. chatter_post now takes an optional subject, passed to message_post(subject=). It is plain text on one line, at most 200 characters: control characters and line breaks become spaces (this also rules out email header injection) and whitespace runs collapse. It is not HTML-escaped, because mail.message.subject is a Char field that Odoo escapes at render time. The subject is part of the canonical payload, so the approval token covers it. Subject-less posts keep their previous token. The compose smoke now posts a subject with & and <b> and checks it is stored verbatim.
4 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chatter_postaccepts an optionalsubject, passed tomessage_post(subject=...).Without a subject, Odoo titles the notification email of a chatter comment with the record name (for example
INV/2026/00036). Callers that send customer-facing messages (a comment with the Discussions subtype, addressed to a partner viapartner_ids) therefore had to fall back to an allow-listed<model>.message_postcall throughexecute_method. With a subject they can stay onchatter_postand its approval gate.The subject is:
Cc) and line/paragraph separators (Zl,Zp) become spaces, and whitespace runs collapse. This also rules out email header injection (\r\nBcc: ...).mail.message.subjectis aCharfield (Odoo 19mail_message.py). Odoo escapes it when rendering the chatter and uses it as the emailSubjectheader, so HTML-escaping it here would show&to recipients. The compose smoke checks it is stored verbatim.Recipients:
partner_idsandsubtype_xmlidwere already supported. For acomment, followers of the subtype are notified too, as in the Odoo UI; that is now stated in the tool docstring.Coverage
Verification
uv run python -m ruff check . uv run python -m mypy src uv run python -m pytest uv run --with import-linter lint-imports uv run python scripts/odoo_compose_smoke.py --versions 19.0 16.0 --timeout 420tests/test_chatter_subject.py: no subject; subject passed withpartner_idsandsubtype_xmlid; multi-line / control-character subject flattened to one line and not HTML-escaped; blank subject treated as absent (same token); length limit; token invalidated when the subject changes or is dropped.&and<b>and checks the storedmail.message.subjectmatches exactly. Passed on 19.0 and 16.0.test_from_path_rejects_file_swapped_for_symlink_after_root_checkfails, as it does onmain.Independent of #72, #73 and #74; it touches
chatter_postnear #74, so whichever lands second needs a small rebase.