Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4507 Tampilan

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
Buang
Jawaban Terbai

<?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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Mar 25
878
0
Jan 25
1023
4
Mar 24
3348
1
Okt 23
5322
1
Sep 22
1322