-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to integrate an owl component in a website page? #2
Comments
@helmidhaoui to integrate an owl component into an Odoo website page, you need to follow these steps:
const { Component, useState } = owl;
const { xml } = owl.tags;
class MyComponent extends Component {
setup() {
this.state = useState({ value: 1 });
}
increment() {
this.state.value++;
}
}
MyComponent.template = xml`<div t-on-click="increment">
<t t-esc="state.value" />
</div>`;
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="myaddon.MyComponent" owl="1">
<div t-on-click="increment">
<t t-esc="state.value" />
</div>
</t>
</templates>
{
'name': 'My Addon',
'version': '1.0',
'depends': ['web'],
'data': [
'views/assets.xml',
],
'qweb': [
'static/src/xml/my_component.xml',
],
'application': True,
}
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="assets_frontend" inherit_id="web.assets_frontend" name="My Addon Assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/myaddon/static/src/js/my_component.js"/>
</xpath>
</template>
</odoo>
<div id="my-component-container"></div>
<script>
owl.utils.whenReady().then(() => {
const myComponent = new MyComponent();
myComponent.mount(document.getElementById("my-component-container"));
});
</script> Alternatively, you can create a website snippet for your component using the For more information on how to use owl components in Odoo, you can refer to the following sources:
Source: Conversation with Bing, 11/19/2023 |
How to integrate an owl component in an Odoo website page?
The text was updated successfully, but these errors were encountered: