Repository navigation
[16.0][FIX] document_page_reference: resolve references with jinja2 3 - #688
Open
parabol123654 wants to merge 1 commit into
Open
parabol123654 wants to merge 1 commit into
parabol123654 wants to merge 1 commit into
Conversation
References are resolved by overriding Context.resolve, but compiled
templates look names up with Context.resolve_or_missing: jinja2 2 only
called an overridden resolve() in a legacy mode, and jinja2 3 (the version
Odoo 16 uses on Python > 3.10) never does. ${reference} placeholders were
then rendered as an empty string, without any error.
Override resolve_or_missing instead, which both versions call.
Fixes OCA#687
Assisted-by: Claude Opus 5.5
Contributor
|
Hi @etobella, |
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.
Fixes #687
document_page_referenceresolves${reference}placeholders by overridingContext.resolve. Compiled templates look names up withContext.resolve_or_missing: jinja2 2.x only routes that call to an overriddenresolve()in its legacy mode, and jinja2 3.x has no such mode. With jinja2 3.1.2 (the version Odoo 16 requires on Python > 3.10) the override is never called, so the placeholders render as an empty string, silently.The fix overrides
resolve_or_missinginstead (as proposed in the issue), which both versions call;refis still read fromself.parent, whereTemplate.render()puts the variables.Tests: the existing tests cover it (
test_check_raw,test_check_reference,test_no_reference). Locally on 16.0 (official odoo:16.0 image, Python 3.9):'Test Page 1' != '');17.0+ does not use jinja2 in this module.
Assisted-by: Claude Opus 5.5