Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4504 Vistas

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
Descartar
Mejor respuesta

<?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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
mar 25
878
0
ene 25
1021
4
mar 24
3344
1
oct 23
5309
1
sept 22
1322