odoo/documentation#19051

Created by fw-bot
Merged at 54532c7b6063eaec3419793e929569b82f923cda

Statuses:

label
odoo-dev:saas-18.3-17.0-xpath-replace-typo-jacw-549117-fw
head
2f7d72142ed339adf6d99c41ce05f7c76c466cad
merged
2 days ago by Jacob Was (jacw)
odoo/documentation
17.0 #19047
18.0 #19049
saas-18.3 #19051
saas-18.4 #19054
19.0 #19055
saas-19.1 #19056
saas-19.2 #19057
saas-19.3 #19058
saas-19.4 #19059
master #19060

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

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