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

I'm trying to create a custom snippet on Odoo (version 18, it's important).

Unfortunately, I'm unable to make the snippet appear on the version 18 website builder edit panel.

I tried with the version 17 and it worked without problem. 

I tried multiple xpath including the one found on the documentation of the version 18 and it doesn't work neither. I either have an error or no snippets showing on the edit panel.

<xpath expr="//t[@t-snippet='website.s_banner']" position="before">
<xpath expr="//div[@id='snippet_effect']//t[@t-snippet][last()]" position="after">
<xpath expr="//div[@id='snippet_structure']/div[@class='o_panel_body']" position="inside">

All of them give me the error

    Element '<xpath expr="//div[@id=&#39;snippet_structure&#39;]">' cannot be located in parent view

The xpath is into the xml inheriting website.snippets.

<template id="snippets" inherit_id="website.snippets">
  <xpath expr="//*[@id='snippet_structure']" position="inside"> <!-- No error but nothing appear -->
    <t t-snippet="website_oxp_2023_ard.s_weather" string="Weather Forecast" t-thumbnail="/website_oxp_2023_ard/static/src/img/s_weather.svg"/>
  </xpath>
</template>

Does anyone know how to add a snippet to Odoo version 18 ?

I also asked it on Stack Overflow

頭像
捨棄
作者 最佳答案

I used this xpath as recommended from stack overflow and it worked.
Unfortunately, yours didn't...
`<xpath expr="//snippets[@id='snippet_content']//t[@t-snippet][last()]" position="after">`

頭像
捨棄
最佳答案

Hi,

Try the below which support Ooo18.<template id="template_name" inherit_id="website.snippets" priority="8">

    <xpath expr="//snippets[@id='snippet_structure']" position="inside">    //your code

</xpath>

</template>


Hope it helps

頭像
捨棄
最佳答案

espere

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
7月 25
388
0
7月 25
1025
4
5月 25
1929
1
5月 25
1489
1
4月 25
1488