跳至内容
菜单
此问题已终结
6 回复
11035 查看

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?

形象
丢弃
最佳答案

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.  

形象
丢弃
编写者

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

编写者

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.

最佳答案

Hello Andrzej,

This is a module that does exactly that:

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

形象
丢弃
相关帖文 回复 查看 活动
0
2月 22
1868
0
2月 21
1893
6
8月 19
10067
1
2月 24
2700
0
2月 24
1392