Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
2819 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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">`

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

espere

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 25
263
0
thg 7 25
894
4
thg 5 25
1758
1
thg 5 25
1319
1
thg 4 25
1278