[T3274] FIX: double-escaped QWeb entities crashing mail template rendering - #2133
Open
danpa32 wants to merge 1 commit into
Open
[T3274] FIX: double-escaped QWeb entities crashing mail template rendering#2133danpa32 wants to merge 1 commit into
danpa32 wants to merge 1 commit into
Conversation
…ering Several mail_template rows have their ">"/"<"/'"'/"'" QWeb comparison/string-literal operators double-escaped (e.g. "&gt;" instead of ">"). Odoo 18's stricter QWeb compiler evaluates the still-escaped "&gt;" text as a Python operator and crashes - found via the "Donation - Thank You Letter" template (T3315), but confirmed present in 76 mail_template rows in compassion_18, 45 of which have no owning module at all (created directly via the UI), so a per-module migration could never reach them. Placed in partner_communication since it's a shared dependency of every affected module and guaranteed installed wherever any of these templates live. Purely mechanical string unescaping, safe regardless of which module (if any) owns the row.
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.
T3274 — Fix onboarding welcome generation
There is another pull-request related to it as I work on 2 different module:
CompassionCH/compassion-switzerland#1792
Original report
Manual test procedure failed at step 11: the "Sponsorship
Onboarding Welcome" and "Sponsorship Onboarding Photo by Post" communications
were both never generated. A previous investigation found a QWeb compilation
error (double-escaped
&gt;) in the "Donation - Thank You Letter"template, a stale
noupdateview crashing on a removed_is_qr_iban()method, and flagged ~80 other
mail_templaterows with the samedouble-escape issue.
Root cause
Two independent bugs, plus one structural gap that turned the first into two
symptoms instead of one:
report_compassion_qr_slipview stuck on stale v14 content. The viewwas reworked for v18 ,
but its
ir_model_datahadnoupdate=True— most likely setautomatically by an in-place edit via the view editor at some point — so
the ordinary module upgrade never reloaded it. This is what actually crashes:
get_sponsorship_payment_slip_attachments()(used by the Welcome config)renders
report_compassion.report_2bvr_sponsorship/report_single_bvr_sponsorship, whicht-calls this view._send_new_dossier()has no per-config error isolation.(
partner_communication_switzerland/models/contracts.py) It loops overconfigs = new_dossier + child_picture(Welcome, then Photo-by-post) witha plain
forloop. When Welcome's iteration raised (bug 7.0 add validation to cron #1), the loopaborted before ever reaching Photo-by-post's iteration. Confirmed via a
throwaway migration script: calling
get_photo_by_post_attachment()andrendering its report directly, in isolation, both succeed — Photo-by-post
has no bug of its own, it's collateral damage from Welcome's crash.
Double-escaped QWeb entities (
&gt;instead of>, same for</"/') in severalmail_templaterows, including a raw% if EXPR:pragma line (never converted to a real<t t-if>, sameclass of bug as T3315) in the Welcome template itself
(
mail_onboarding_sponsorship_confirmation,en_US/it_IT), plus a dead% set könnt = ...line inde_DE. Surveyed the whole DB: 76mail_templaterows affected, 45 of which have no owning module at all(created directly via the UI) — a per-module migration could never reach
those.
fr/de/it translations of Python-sourced strings silently ignored.
Found manually while testing the fixes above: the Welcome email's
payment-slip sentence rendered in English on an otherwise-French
communication. Root cause: Odoo 18 only loads a
.poentry as a Pythoncode translation if its comment block contains a
#. odoo-pythonmarkerline (
odoo/tools/translate.py'sCodeTranslations).partner_ communication_switzerland'sde.po/fr_CH.po/it.postill use thepre-v17 comment format (
#, python-format, no#. odoo-python), carriedover from the v14 migration and never regenerated — so every
_()-translated string sourced from Python code in this module silentlyfell back to English for these three languages, regardless of the
.pofile actually having a correct translation. Verified this is not unique
to this one phrase: 43/42/42 entries respectively in these three files
use the old format; this old-format issue exists in 12
.pofiles acrosscompassion-switzerland and 23 across compassion-modules — out of scope
here (own ticket), only fixed for this module's fr/de/it files in this
ticket.
What changed
2 repos:
compassion-switzerland
report_compassion: pre-migration clearing thestale
noupdateflag onreport_compassion_qr_slipso the existing(already-correct) tracked view reloads.
partner_communication_switzerland/models/contracts.py:_send_new_dossiernow wraps each config's send in a savepoint + try/except, logs and
continues on failure instead of aborting the rest.
partner_communication_switzerland: migrationconverting the raw pragma lines in the Welcome template's
body_html(
en_US,it_IT,de_DE).partner_communication_switzerland/i18n/{de,fr_CH,it}.po: added themissing
#. odoo-pythonmarker to every Python-code-sourced entry(mechanical, comment-only change, no msgid/msgstr edits).
compassion-modules:
partner_communication: migration doing apurely mechanical unescape of
&gt;/&lt;/&quot;/&apos;across every
mail_templaterow regardless of owning module (placed heresince it's a shared dependency guaranteed installed wherever any of these
templates live).
Out of scope
SUB sponsorships: confirmed by design, zero automated communication is
sent when a sponsorship validates in
sds_state == "sub"— staff sends the"SUB Accept" letter manually. Unchanged since 2021. If the acceptance
criterion "correct communication for SUB" means this should become
automatic, that's a product decision, not a bug fix — not touched in this
ticket.
Also not touched:
report_compassion_qr_parentandcommunication_style(
report_compassion) are independentlynoupdate=Truein the DB despitetheir files not being
noupdateby design — same class of anomaly as bug#1 above, but not on the crash path for these two onboarding communications.
Worth a follow-up ticket if they turn out to matter elsewhere.
How to test manually
-u report_compassion,partner_communication_ switzerland,partner_communication,recurring_contract)pay first invoice → check communications).
and "Sponsorship Onboarding - Photo by post" jobs are created and reach
"ready"/"done", with the payment slip PDF attached to Welcome and the
Welcome email body free of visible
%/code text.