Ir al contenido
Menú
Se marcó esta pregunta
6 Respuestas
10533 Vistas

I'm trying to add my logo to the top navbar like this:

https://i.imgur.com/0J54fbh.png

I modified the xml file "addons\web\static\src\xml\menu.xml" and added my div inside the header:

<header t-name="Menu">
  <nav class="o_main_navbar">
      <ul class="o_menu_apps"/>
      <div style="height: 100%;display: block;float: left;margin-right: 15px;margin-left: 15px;">
          <img src="https://www.clubsportive.nl/wp-content/uploads/2018/12/logo-example.jpg" height=100%/>
      </div>
      <a class="o_menu_brand" role="button"/>
      <ul class="o_menu_sections" role="menu"/>
      <ul class="o_menu_systray" role="menu"/>
  </nav>
</header>

But it breaks whole odoo. I see only white screen.

In console I have errors like this:
https://i.imgur.com/MSPCNni.png

How do I do this?

Avatar
Descartar
Mejor respuesta

Never modify the original files, create an custom module and inherit the template. Look at the assets what version of bootstrap it uses and then use xpath to add into it the "brand" class and add img into it.  

Avatar
Descartar
Autor

I'm having trouble locating the view to inherit. What is ID of the view resposible for the top navbar? How do I targed propper element with xpath?

this is for menu of odoo10 <template id="logo_menu_addition" inherit_id="web.menu">, xpath example <xpath expr="//nav[@id='oe_main_menu_navbar']" position="after">. https://www.w3schools.com/xml/xml_xpath.asp

Autor

Sadly this does not work anymore. Any idea how to get the current model?

It was just an example for you as a guideline how to try to do it on odoo 12, so the id in xpath maybe doesn't even exist, because it uses a newer bootstrap. The inherited ID is from adding something to the odoo 10 backend menu, not a logo. I'm not working yet on odoo 12. If you're trying to do this to a website then just find a template that has that feature and copy the code. Odoo 12 has a different menu structure than Odoo 10 in the backend.

Mejor respuesta

Hello Andrzej,

This is a module that does exactly that:

https://apps.odoo.com/apps/modules/12.0/web_company_logo/

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
feb 22
1458
0
feb 21
1373
6
ago 19
9300
1
feb 24
1626
0
feb 24
775