[18.0] [FIX] mail_debrand: debrand auth_signup emails - #261
Open
nimarosa wants to merge 2 commits into
Open
Conversation
Contributor
|
Hi @joao-p-marques, @pedrobaeza, |
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
force-pushed
the
18.0-fix-mail_debrand-auth_signup
branch
from
September 1, 2026 15:42
8b68c38 to
33f33ec
Compare
…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.
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.
What was broken
mail_debrand's own README lists it as a known issue:Rendering the two
auth_signupmails on 18.0 withmail_debrandinstalled (text extracted from the actual outgoing body) gives:New user invitation (
auth_signup.set_password_email, sent by_action_reset_passwordin create mode)…with the subject
OdooBot from YourCompany invites you to connect to Odoo.Password reset (
auth_signup.reset_password_email)Root cause
The hook is not being bypassed — both mails do go through
mail.render.mixin._render_template(the reset password one viaengine="qweb_view", the invitation viamail.template.send_mail), andmail.mail._prepare_outgoing_bodyruns on top. The problem is whatremove_href_odoodoes: it only looks for//a[contains(@href,"odoo.com")], removes those anchors and blanks the text node immediately before them. That is enough for thePowered by <a>Odoo</a>footer ofmail_notification_layout, butauth_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
remove_odoo_mentionsreplaces 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 — sohref,srcand 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.pngandOdooBotare all left alone, so only the branding is debranded, never the data of the records.Configurable with the
mail_debrand.brand_replacementsystem parameter: unset → the company name, any value → that value,False→ feature off (only the links are removed, i.e. the previous behaviour).The promotional block that comes with a removed link is dropped too. When an
odoo.comanchor 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 removesNever 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.The
to_keepprotection (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:
OdooBotabove 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: theAccept invitationbutton survives,www.odoo.com,to discover the tooland the wholeNever heard of…block are gone, no standalone brand mention is left in the body or in the subject, andWelcome to <company>is there.test_debrand_auth_signup_reset_password_email— new, exercises theqweb_viewrender +_prepare_outgoing_bodypath exactly as_action_reset_passworddoes;Change passwordsurvives, no brand mention left.test_record_data_is_not_debranded— new, a user namedOdooBot Sanchezwithodoobot.sanchez@example.comkeeps 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 noodoo.comand no standalone brand mention.Closes the
auth_signupknown issue listed in the module's ROADMAP.