Skip to content

[18.0] [FIX] mail_debrand: debrand auth_signup emails - #261

Open
nimarosa wants to merge 2 commits into
OCA:18.0from
nimarosa:18.0-fix-mail_debrand-auth_signup
Open

[18.0] [FIX] mail_debrand: debrand auth_signup emails#261
nimarosa wants to merge 2 commits into
OCA:18.0from
nimarosa:18.0-fix-mail_debrand-auth_signup

Conversation

@nimarosa

@nimarosa nimarosa commented Sep 1, 2026

Copy link
Copy Markdown

What was broken

mail_debrand's own README lists it as a known issue:

Not all branding is removed from auth_signup's invitation email because it is a longer, more complex snippet of HTML. Only the line containing the link to Odoo.com is removed.

Rendering the two auth_signup mails on 18.0 with mail_debrand installed (text extracted from the actual outgoing body) gives:

New user invitation (auth_signup.set_password_email, sent by _action_reset_password in create mode)

Welcome to Odoo — Dear Marc Demo, You have been invited by OdooBot of YourCompany to connect on Odoo. [Accept invitation] This link will remain valid during 6 days. Your Odoo domain is: … Never heard of Odoo? It's an all-in-one business software loved by 7+ million users. It will considerably improve your experience at work and increase your productivity. Enjoy Odoo!

…with the subject OdooBot from YourCompany invites you to connect to Odoo.

Password reset (auth_signup.reset_password_email)

A password reset was requested for the Odoo account linked to this email.

Root cause

The hook is not being bypassed — both mails do go through mail.render.mixin._render_template (the reset password one via engine="qweb_view", the invitation via mail.template.send_mail), and mail.mail._prepare_outgoing_body runs on top. The problem is what remove_href_odoo does: it only looks for //a[contains(@href,"odoo.com")], removes those anchors and blanks the text node immediately before them. That is enough for the Powered by <a>Odoo</a> footer of mail_notification_layout, but auth_signup's templates write the brand as prose, with no link attached, so every one of those mentions survived. The subject is not HTML at all, so nothing was ever removed from it.

Note the module's own manifest summary has claimed since v12 that it "removes any 'odoo' that are in template texts > 20 characters" — that behaviour never actually existed in the code.

The fix

  1. remove_odoo_mentions replaces the remaining standalone mentions of the brand by the name of the company (Welcome to Acme, Enjoy Acme!, A password reset was requested for the Acme account…), which keeps the sentences readable instead of leaving holes in them. It runs on text nodes only — the value is split on HTML tags and only the text chunks are substituted — so href, src and any other attribute keeps its value. It works on plain strings too, which is what fixes the subject.

    Word boundaries are strict: (?<![\w./@-])odoo(?![\w@/]|[.-]\w). odoo.com, www.odoo.sh, odoobot@example.com, /web/static/img/odoo-logo.png and OdooBot are all left alone, so only the branding is debranded, never the data of the records.

    Configurable with the mail_debrand.brand_replacement system parameter: unset → the company name, any value → that value, False → feature off (only the links are removed, i.e. the previous behaviour).

  2. The promotional block that comes with a removed link is dropped too. When an odoo.com anchor is removed, the preceding sibling text runs are also cleared while they mention the brand, stopping at the first one that belongs to the actual message. That is what removes Never heard of Odoo? It's an all-in-one business software loved by 7+ million users. … from the invitation — a sentence that would be plainly false if it were merely rebranded.

  3. The to_keep protection (the user's own message body) now wraps both passes, so a message that legitimately talks about Odoo is still never modified.

Result, same two mails:

Welcome to Acme — Dear Marc Demo, You have been invited by OdooBot of Acme to connect on Acme. [Accept invitation] This link will remain valid during 6 days. Your Acme domain is: … Enjoy Acme!

A password reset was requested for the Acme account linked to this email.

OdooBot above is the inviting user's name, a record value; the module deliberately does not rewrite it, and the README's known-issues section now says so instead of the auth_signup entry.

Tests

mail_debrand/tests/, 14 tests, all green on a real 18.0 database:

  • test_debrand_auth_signup_set_password_email — extended: the Accept invitation button survives, www.odoo.com, to discover the tool and the whole Never heard of… block are gone, no standalone brand mention is left in the body or in the subject, and Welcome to <company> is there.
  • test_debrand_auth_signup_reset_password_email — new, exercises the qweb_view render + _prepare_outgoing_body path exactly as _action_reset_password does; Change password survives, no brand mention left.
  • test_record_data_is_not_debranded — new, a user named OdooBot Sanchez with odoobot.sanchez@example.com keeps both in the mail.
  • test_remove_odoo_mentions, …_keeps_technical_values, …_custom_replacement, …_disabled — new unit tests for the replacement itself.

Also verified end to end on a dev stack: the mails actually delivered to the SMTP catcher (invitation on user creation and action_reset_password()) contain no odoo.com and no standalone brand mention.

Closes the auth_signup known issue listed in the module's ROADMAP.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @joao-p-marques, @pedrobaeza,
some modules you are maintaining are being modified, check this out!

The module only removed the anchors pointing to odoo.com and the words
right before them, so the templates that write the brand as prose kept
it. auth_signup's mails are the documented case: after debranding they
still read "Welcome to Odoo", "You have been invited ... to connect on
Odoo", "Your Odoo domain is:", "Never heard of Odoo? It's an all-in-one
business software loved by 7+ million users.", "Enjoy Odoo!", and the
password reset one "A password reset was requested for the Odoo account
linked to this email". The invitation subject ("... invites you to
connect to Odoo") was branded too.

Replace the remaining standalone mentions of the brand by the name of
the company, on text nodes only, and drop the promotional block that
precedes a removed branding link. The replacement is configurable
through the mail_debrand.brand_replacement system parameter and can be
switched off with the "False" value.

Word boundaries are checked so that URLs, e-mail addresses and longer
identifiers (odoo.com, odoobot@example.com, OdooBot) are never touched:
only the branding is debranded, never the data of the records.
@nimarosa
nimarosa force-pushed the 18.0-fix-mail_debrand-auth_signup branch from 8b68c38 to 33f33ec Compare September 1, 2026 15:42
…m opt-out

The double-space cleanup only ran with an empty replacement, which cannot
happen: an empty ir.config_parameter is removed rather than stored, so the
value always falls back to the company name.

Add the missing test for the dev.odoo.com escape hatch, which keeps a mail
untouched when it links to the development site.
@nimarosa nimarosa changed the title [FIX] mail_debrand: debrand auth_signup emails [18.0] [FIX] mail_debrand: debrand auth_signup emails Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants