How to Make Odoo Snippet Options

TEAM-BASSAM
July 1, 2024
how-to-make-odoo17-snippet-option

Odoo website snippets are reusable and standard elements that make a web page and website creation and customization easier. These building elements allow users to create dynamic, aesthetically pleasing online content. let’s go into a complete overview of how to make the odoo snippets option in Odoo 17 in this blog.

Odoo website snippets let you add editable components to website snippets that appear on your website. Users can customize the content of the websites to needs by adding text, graphics, buttons, and other features to the website page. this tool is for Businesses trying to develop a distinctive brand.

Step 1: Configuring Your Odoo Snippet Environment

NB. Ensure Odoo 17 is installed and configured on your server before we start.

Step 2: Developing a New Snippet Option in Odoo 17

It help if you defined snippet options in your custom module to create them. Create a new module initially, or use an already existing one. Assume for the purposes of this example that you have a module called “custom_website.

Launch the manifest file for your module (custom_website/manifest.py) and include the following code

manifest-file-in-odoo-snippet-option

To define odoo snippet to which we will add options, create a new XML file:

odoo snippet


After defining the snippet, let’s proceed to include it in the snippet blocks within the website editor. ‘website. odoo snippets’ must be inherited in order for us to add our snippet:

To view the custom snippet among the snippet blocks, let’s update the module now.

the custom snippet

We can view our personalized excerpt here. Let’s now add options to our snippet by creating a new XML file. We must inherit the website in order to do that—template snippet_options.

template-snippet_options-code
template-snippet_options

The choice is now visible, but we have only finished creating the button; its functionality still needs to added. To do that, let’s extend the class “options” and create a javascript file with a function for that option:

As previously stated, the data-js element is used for our custom class, “CustomSnippet,” to the snippet choice. In this case, the function uses the clone() method to retrieve the final snippet item. We can add extra elements to the snippet by appending it to the parent container. The ‘data-add-item’ property provided in the odoo website snippet option calls this function.

Now lets us examine the odoo 17 snippet operation

odoo snippet

By repeatedly selecting the “add item” option, we can observe that the number of odoo 17 snippet items increased. Remember to include our js file in the manifest.

You have now successfully added snippet option to a snippets on your website in Odoo 17. There are countless ways to personalize your internet appearance with this strong feature. Try out various settings, look into extra features, and take your website to new places.

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *