Skip to Content
Menu
This question has been flagged
3 Replies
2124 Views

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

Avatar
Discard
Author Best Answer

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

espere

Avatar
Discard
Related Posts Replies Views Activity
1
May 25
579
1
Apr 25
472
0
Mar 25
398
1
Feb 25
379
0
Feb 25
516