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