Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
4500 Weergaven

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>


Avatar
Annuleer
Beste antwoord

<?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

Avatar
Annuleer
Beste antwoord

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!

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 25
873
0
jan. 25
1018
4
mrt. 24
3339
1
okt. 23
5307
1
sep. 22
1322