[19.0][FIX] project_task_description_template: make tests robust to HTML field wrapping#1739
Merged
OCA-git-bot merged 1 commit intoMay 29, 2026
Conversation
…eld wrapping The two onchange tests pinned the exact wrapper tag of the appended template text. Odoo core flips that wrapper between releases (<span> <-> <p>), so the hard-coded assertions break on every change. Compare against the template's own stored Html value instead, so both sides track whatever core produces.
leemannd
approved these changes
May 29, 2026
Contributor
|
/ocabot merge patch |
Contributor
|
What a great day to merge this nice PR. Let's do it! |
Contributor
|
Congratulations, your PR was merged at dbc4fef. Thanks a lot for contributing to OCA. ❤️ |
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.
TestDescriptionTemplatefails on 19.0, and the failure oscillates: the twoonchange assertions pin the exact HTML wrapper of the appended template text,
but that wrapper is not stable across Odoo nightlies.
Root cause
The
Htmlfield runs core'shtml_sanitize()(odoo/tools/mail.py) on write.For tagless input its
fromstring()returns the element libxml2 auto-createswhen it wraps the loose text in a
<p>, and otherwise falls back to tagging thebody
<span>. Whether libxml2 auto-wraps tagless text drifts betweenOdoo/lxml builds — the assertions were flipped
<p>→<span>only days ago andare failing again now that core emits
<p>. The module input(
" - Sample Description") never changed; only the sanitiser output moved.Fix
Compare the result against the template's own stored Html value rather than
a hard-coded string. Both sides pass through the same sanitiser, so they agree
regardless of which branch of that code runs — no more tag flip-flop. Module
behaviour is unchanged, and the only remaining literal (
<p>Existing Description</p>) is a block element, stable across both regimes.Verified on a clean
odoo:19.0(--test-enable --without-demo=all): both testspass (
0 failed, 0 error(s) of 2 tests).