Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4502 Widoki

Hi, i tried to modify the menu toggle title inheriting website.user_navbar. But i got the follow error:

the element '' Cannot be located in parent view


Seeing the template "user_navbar" i saw that

    is present. Following, you can see my code:


xml version="1.0" encoding="utf-8"?>
<
odoo>
<template id="dondi_user_navbar" inherit_id="website.user_navbar">
<xpath expr="//ul['id=oe_applications']" position="replace">
<a href="#" class="fa fa-th o_menu_toggle" title="[Text here]" aria-label="
"[Text here]"
"/>
xpath>
<
xpath expr="//ul[hasclass('o_menu_sections')]" position="before">
<div class="o_menu_brand">Websitediv>
xpath>
template>
odoo>


Awatar
Odrzuć
Najlepsza odpowiedź

<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <template id="dondi_user_navbar" inherit_id="website.user_navbar">

        <!-- Example: replace the ul with id='oe_applications' -->

        <xpath expr="//ul[@id='oe_applications']" position="replace">

            <a href="#" class="fa fa-th o_menu_toggle" title="[Text here]" aria-label="[Text here]"/>

        </xpath>


        <!-- Insert a brand div before the menu sections -->

        <xpath expr="//ul[contains(@class, 'o_menu_sections')]" position="before">

            <div class="o_menu_brand">Website</div>

        </xpath>

    </template>

</odoo>


i hope it is use full

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,


The issue here is with the syntax of your xpath expression.

When targeting an element by its id, you should use @id, and for classes, hasclass('class_name'). In your code, the first xpath expression is written like this:


<xpath expr="//ul['id=oe_applications']" position="replace">

This is incorrect and will cause the error you’re seeing: "the element '' cannot be located in parent view."

To fix it, update the line to:

<xpath expr="//ul[@id='oe_applications']" position="replace">

Once you make that change, the element should be located properly, and the error should be resolved.

Hope it helps!

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 25
874
0
sty 25
1018
4
mar 24
3341
1
paź 23
5308
1
wrz 22
1322