[FIX] reference/user_interface: typo in xpath replace position example#19051
Closed
fw-bot wants to merge 1 commit into
Closed
[FIX] reference/user_interface: typo in xpath replace position example#19051fw-bot wants to merge 1 commit into
fw-bot wants to merge 1 commit into
Conversation
The `xpath` node has a feature in the `replace` position which copies
the node matched by the xpath expression. This feature looks for an
element with text exactly equal to `$0`; newlines, whitespace
characters, and other nodes will prevent the characters from being
recognized.
This behavior is defined in the following odoo Community file. Note
that `text()='$0'` looks for an exact match, while
`contains(text(),'$0')` would instead match on any text containing
those characters.
```py
for loc in spec.xpath(".//*[text()='$0']"):
loc.text = ''
copied_node = copy.deepcopy(node)
# TODO: Remove 'inherit_branding' logic if possible;
# currently needed to track node removal for branding
# distribution. Avoid marking root nodes to prevent
# sibling branding issues.
if inherit_branding:
copied_node.set('data-oe-no-branding', '1')
loc.append(copied_node)
```
https://github.com/odoo/odoo/blob/17.0/odoo/tools/template_inheritance.py#L151-L160
Thus, the example code for this behavior is incorrect, as it includes
several newlines and spaces. The text itself is correct.
task-6408040
X-original-commit: d6ac0cf
Collaborator
Collaborator
Author
|
This PR targets saas-18.3 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
robodoo
pushed a commit
that referenced
this pull request
Jul 22, 2026
The `xpath` node has a feature in the `replace` position which copies
the node matched by the xpath expression. This feature looks for an
element with text exactly equal to `$0`; newlines, whitespace
characters, and other nodes will prevent the characters from being
recognized.
This behavior is defined in the following odoo Community file. Note
that `text()='$0'` looks for an exact match, while
`contains(text(),'$0')` would instead match on any text containing
those characters.
```py
for loc in spec.xpath(".//*[text()='$0']"):
loc.text = ''
copied_node = copy.deepcopy(node)
# TODO: Remove 'inherit_branding' logic if possible;
# currently needed to track node removal for branding
# distribution. Avoid marking root nodes to prevent
# sibling branding issues.
if inherit_branding:
copied_node.set('data-oe-no-branding', '1')
loc.append(copied_node)
```
https://github.com/odoo/odoo/blob/17.0/odoo/tools/template_inheritance.py#L151-L160
Thus, the example code for this behavior is incorrect, as it includes
several newlines and spaces. The text itself is correct.
task-6408040
closes #19051
X-original-commit: d6ac0cf
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Jacob Was (jacw) <jacw@odoo.com>
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.

The
xpathnode has a feature in thereplaceposition which copies the node matched by the xpath expression. This feature looks for an element with text exactly equal to$0; newlines, whitespace characters, and other nodes will prevent the characters from being recognized.This behavior is defined in the following odoo Community file. Note that
text()='$0'looks for an exact match, whilecontains(text(),'$0')would instead match on any text containing those characters.https://github.com/odoo/odoo/blob/17.0/odoo/tools/template_inheritance.py#L151-L160
Thus, the example code for this behavior is incorrect, as it includes several newlines and spaces.
task-6408040 Link
Forward-Port-Of: #19047