跳至內容
選單
此問題已被標幟
2 回覆
4536 瀏覽次數

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>


頭像
捨棄
最佳答案

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

頭像
捨棄
最佳答案

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!

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 25
902
0
1月 25
1042
4
3月 24
3391
1
10月 23
5350
1
9月 22
1322