Enable Dark Mode!
how-to-create-a-snippet-in-odoo-17.jpg
By: Subina P

How to Create a Snippet in Odoo 17

Technical Odoo 17

Odoo offers user-friendly and efficient website management tools, enabling users to easily create and customize websites. These tools include a drag-and-drop feature for snippets. The website editor in Odoo provides various editing building blocks that users can drag and drop onto their pages, customizing them as needed. Additionally, users can learn to create their building blocks. Odoo categorizes snippets into two main types: static snippets, which remain fixed until modified by the user, and dynamic snippets, which are based on datasets and stored in the Odoo backend.

How to Create a Static Snippet?

1. Create a template for the snippet.

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="basic_snippet" name="Basic Snippet">
      <section class="container">
          <div class="row">
              <div class="col-md-12">
                  <h1>Basic Snippet.........</h1>
                  <p>This is a basic snippet that is used to test the basic functionality of the snippets.</p>
              </div>
          </div>
      </section>
   </template>
  </odoo>

2. Record the snippet as static

The provided XML code extends the website.snippets template in Odoo 17, specifically targeting the div with id='snippet_content.' It inserts a new snippet with the title 'blog_snippet.basic_snippet' after the last existing snippet in the designated position.

<template id="external_snippets" inherit_id="website.snippets" priority="8">
  <xpath expr="//div[@id='snippet_content']//t[@t-snippet][last()]"             position="after">
       <t t-snippet="blog_snippet.basic_snippet"/>
</xpath>
</template>

Now, we have to add this file to __manifest_.py inside the data section.

Then after installing or upgrading the module, click on the edit on the website, and we can see our snippet under the features, and we can drag and drop the snippet.

how-to-create-a-snippet-in-odoo-17-1-cybrosys

Overall, Odoo's website management tools offer a user-friendly and efficient way to create and customize websites. Whether you're creating static snippets or dynamic snippets, Odoo provides the tools you need to create a professional-looking website that meets your needs.

To read more about creating a snippet in Odoo 16, refer to our blog How to Create a Snippet in Odoo 16


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message