Skip to Content
Menu
This question has been flagged
1 Reply
1634 Views

Hello, I was trying to create a website snippet in owl. I already read the Odoo Docs about Javascript and Owl Modules, but i don't know how I can do a snippet widget.
My code was:


My views/views.xml:

xml version="1.0" encoding="utf-8"?><odoo> <data> <templateid="test_widget"name="Testimonial snippet"> <sectionclass="test_widget"> <divclass="container"> <divclass="row"> <tt-name="tbd_pis.test"owl="1"> <divt-on-click="increment"> <tt-esc="state.value" /> div> t> div> div> section> template>
<templateid="place_into_bar"inherit_id="website.snippets"name="Place into bar"> <xpathexpr="//div[@id='snippet_structure']/div[hasclass('o_panel_body')]"position="inside"> <tt-snippet="tbd_pis.test_widget"t-thumbnail="/tbd_pis/static/src/img/luis.jpg"owl="1" /> xpath> template>
/data>/odoo>

My static/src/js/components/test.js:
odoo.define("tbd_pis.test", function (require) {                                
    constFormRenderer=require("web.FormRenderer"); 
    const { Component } =owl; 
    const { ComponentWrapper } =require("web.OwlCompatibility"); 
    class Test extends Component {
        setup() {
            this.state = useState({ value: 1 });
        }
        increment() {
            this.state.value++;
        }; 
    Object.assign(Test, { template: "tbd_pis.test"    });
}); 


My part of __manyfest__.py
'depends': ['base', 'website_sale', 'website', 'web_editor'],
"data": ['views/views.xml' ],
'assets': {
    'web.assets_backend': ["static/src/js/components/test.xml"        ],
    'web.assets_common': ["static/src/js/components/test.js"        ],
 },


Odoo version: Odoo 16 Docker

if someone send me a example or some documentation, I'm very grateful

Avatar
Discard
Related Posts Replies Views Activity
4
Nov 24
794
1
Feb 24
959
1
Mar 23
1217
1
Aug 21
3222
1
Mar 17
1957