Skip to content

[FIX] reference/user_interface: typo in xpath replace position example#19051

Closed
fw-bot wants to merge 1 commit into
saas-18.3from
saas-18.3-17.0-xpath-replace-typo-jacw-549117-fw
Closed

[FIX] reference/user_interface: typo in xpath replace position example#19051
fw-bot wants to merge 1 commit into
saas-18.3from
saas-18.3-17.0-xpath-replace-typo-jacw-549117-fw

Conversation

@fw-bot

@fw-bot fw-bot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

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.

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.

task-6408040 Link

Forward-Port-Of: #19047

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
@robodoo

robodoo commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Pull request status dashboard

@fw-bot

fw-bot commented Jul 22, 2026

Copy link
Copy Markdown
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>
@robodoo robodoo closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants