Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
812 Представления

I'd like to add a menu to the odoo site. I wanted to inject the new item directly into model.website, but I've noticed that it persists in the database and if I change the url, I have to raze everything before it takes. I read somewhere that I could do template inheritance, but I don't understand how it works. I've looked through articles without really understanding. I still have this error, but when I go to the browser inspector, I can see this class.


Error : "RPC_ERROR


Odoo Server Error


Occured on localhost:8069 on model ir.module.module and id 34 on 2025-07-21 13:07:12 GMT


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/convert.py", line 548, in _tag_root

    raise ParseError(msg) from None  # Restart with "--log-handler odoo.tools.convert:DEBUG" for complete traceback

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

odoo.tools.convert.ParseError: while parsing None:7

Erreur lors du parsing ou de la validation de la vue :


L'élément '<xpath expr="//ul[@id=&#39;top_menu&#39;]">' ne peut être localisé dans la vue parente


View error context:

{'file': '/mnt/extra-addons/visit_veone/views/visit_veone_custom_menu.xml',

'line': 1,

'name': 'Ajouter lien visite (desktop)',

'view': ir.ui.view(1436,),

'view.model': False,

'view.parent': ir.ui.view(611,),

'xmlid': 'visit_veone_menu_item'}



The above server error caused the following client error:

RPC_ERROR: Odoo Server Error

    RPCError@http://localhost:8069/web/assets/eef1bc0/web.assets_web.min.js:3141:338

    makeErrorFromResponse@http://localhost:8069/web/assets/eef1bc0/web.assets_web.min.js:3144:163

    rpc._rpc/promise</<@http://localhost:8069/web/assets/eef1bc0/web.assets_web.min.js:3149:34

   "

Аватар
Отменить

Have you tried to implement the new menu with studio?

Please share visit_veone/views/visit_veone_custom_menu.xml as this results in an error according to your post.

Лучший ответ

Hii,

Find the Correct Parent Template

The top menu is usually part of:

<template id = "website.layout" ... >

So you want to inherit from that.

Create Your XML View

Here's a working example that injects a link into the top menu bar:

<!-- File: visit_veone/views/visit_veone_custom_menu.xml --> <odoo> <template id = "visit_veone_menu_item" inherit_id = "website.layout"> <xpath expr = "//header//nav//ul[contains(@class, 'o_menu_sections')]" position = "inside"> <li class = "nav-item"> <a class = "nav-link" href = "/my-custom-url" >Visit Page </a> </li> </xpath> </template> </ odoo >

This will add a new top menu link to /my-custom-url .

Include It in Your Manifest

Make sure visit_veone_custom_menu.xml is loaded in your __manifest__.py :

'data' : [ 'views/visit_veone_custom_menu.xml' , ],

How to Avoid "Element Not Found" XPath Errors
Tips:
  • Inspect the rendered HTML in the browser , and search for the element (eg, ul.o_menu_sections ) to confirm it exists.
  • Do not guess IDs like top_menu unless you see them explicitly in the template. Odoo's website uses classes more than IDs.

i hope it is usefull

Аватар
Отменить
Автор

Thanks ! It works properly rights now.

Лучший ответ

Hi,


Refer to the following



* https://www.cybrosys.com/blog/how-to-create-menu-pages-and-mega-menu-in-website-odoo-18

* https://www.cybrosys.com/odoo/videos/technical/how-to-add-menu-in-odoo-website

* https://www.cybrosys.com/blog/how-to-create-menu-pages-and-mega-menu-in-website-odoo-18



Hope it helps

Аватар
Отменить
Автор

Thank you so much! I love your tutorials! You explain the concept in great detail and it's very impressive.

Related Posts Ответы Просмотры Активность
Get menuitem list Решено
3
дек. 21
6896
0
дек. 18
2410
7
окт. 18
22063
2
нояб. 17
6278
0
апр. 17
2529