diff --git a/content/developer/howtos/frontend_owl_components.rst b/content/developer/howtos/frontend_owl_components.rst index add8cbebb..d1ab14b9b 100644 --- a/content/developer/howtos/frontend_owl_components.rst +++ b/content/developer/howtos/frontend_owl_components.rst @@ -36,7 +36,6 @@ and add it to the `public_components` registry: .. code-block:: js - /** @odoo-module */ import { Component } from "@odoo/owl"; import { registry } from "@web/core/registry" diff --git a/content/developer/howtos/javascript_client_action.rst b/content/developer/howtos/javascript_client_action.rst index 8ae72eacb..e3e4f0b34 100644 --- a/content/developer/howtos/javascript_client_action.rst +++ b/content/developer/howtos/javascript_client_action.rst @@ -29,8 +29,9 @@ framework and use services, core components, hooks,... import { Component } from "@odoo/owl"; - class MyClientAction extends Component {} - MyClientAction.template = "my_module.clientaction"; + class MyClientAction extends Component { + static template = "my_module.clientaction"; + } // remember the tag name we put in the first step registry.category("actions").add("my_module.MyClientAction", MyClientAction); diff --git a/content/developer/howtos/javascript_field.rst b/content/developer/howtos/javascript_field.rst index 70df6edc3..7f6764e0b 100644 --- a/content/developer/howtos/javascript_field.rst +++ b/content/developer/howtos/javascript_field.rst @@ -18,8 +18,9 @@ displaying "Late!" in red whenever the checkbox is checked. import { BooleanField } from "@web/views/fields/boolean/boolean_field"; import { Component, xml } from "@odoo/owl"; - class LateOrderBooleanField extends BooleanField {} - LateOrderBooleanField.template = "my_module.LateOrderBooleanField"; + class LateOrderBooleanField extends BooleanField { + static template = "my_module.LateOrderBooleanField"; + } #. Create the field template. @@ -66,23 +67,20 @@ Assume that we want to create a field that displays a simple text in red. import { registry } from "@web/core/registry"; export class MyTextField extends Component { + static template = xml` + + `; + static props = { ...standardFieldProps }; + static supportedTypes = ["char"]; - /** - * @param {boolean} newValue - */ - onChange(newValue) { - this.props.update(newValue); - } + /** + * @param {boolean} newValue + */ + onChange(newValue) { + this.props.update(newValue); + } } - MyTextField.template = xml` - - `; - MyTextField.props = { - ...standardFieldProps, - }; - MyTextField.supportedTypes = ["char"]; - The imported `standardFieldProps` contains the standard props passed by the `View` such as the `update` function to update the value, the `type` of the field in the model, the `readonly` boolean, and others. diff --git a/content/developer/howtos/javascript_view.rst b/content/developer/howtos/javascript_view.rst index 530e51482..a939054fd 100644 --- a/content/developer/howtos/javascript_view.rst +++ b/content/developer/howtos/javascript_view.rst @@ -20,12 +20,12 @@ can be done in a few steps: // the controller usually contains the Layout and the renderer. class CustomKanbanController extends KanbanController { + static template = "my_module.CustomKanbanView"; + // Your logic here, override or insert new methods... // if you override setup(), don't forget to call super.setup() } - CustomKanbanController.template = "my_module.CustomKanbanView"; - export const customKanbanView = { ...kanbanView, // contains the default Renderer/Controller/Model Controller: CustomKanbanController, @@ -85,6 +85,9 @@ Creating a new view is an advanced topic. This guide highlight only the essentia import { Component, onWillStart, useState} from "@odoo/owl"; export class BeautifulController extends Component { + static template = "my_module.View"; + static components = { Layout }; + setup() { this.orm = useService("orm"); @@ -106,9 +109,6 @@ Creating a new view is an advanced topic. This guide highlight only the essentia } } - BeautifulController.template = "my_module.View"; - BeautifulController.components = { Layout }; - The template of the Controller displays the control panel with Layout and also the renderer. @@ -133,9 +133,9 @@ Creating a new view is an advanced topic. This guide highlight only the essentia :caption: :file:`beautiful_renderer.js` import { Component } from "@odoo/owl"; - export class BeautifulRenderer extends Component {} - - BeautifulRenderer.template = "my_module.Renderer"; + export class BeautifulRenderer extends Component { + static template = "my_module.Renderer"; + } .. code-block:: xml :caption: :file:`beautiful_renderer.xml` diff --git a/content/developer/howtos/website_themes/building_blocks.rst b/content/developer/howtos/website_themes/building_blocks.rst index 2e6735776..255fbfff0 100644 --- a/content/developer/howtos/website_themes/building_blocks.rst +++ b/content/developer/howtos/website_themes/building_blocks.rst @@ -380,8 +380,6 @@ The `data-js` attribute can be assigned to an options group in order to define a .. code-block:: javascript - /** @odoo-module */ - import options from 'web_editor.snippets.options'; options.registry.CustomMethodName = options.Class.extend({ diff --git a/content/developer/reference/frontend/framework_overview.rst b/content/developer/reference/frontend/framework_overview.rst index 4976f30bf..63d155395 100644 --- a/content/developer/reference/frontend/framework_overview.rst +++ b/content/developer/reference/frontend/framework_overview.rst @@ -152,9 +152,10 @@ client can use it. For example, the field registry contains all field components .. code-block:: javascript + import { Component } from "@odoo/owl"; import { registry } from "./core/registry"; - class MyFieldChar extends owl.Component { + class MyFieldChar extends Component { // some code } diff --git a/content/developer/reference/frontend/hooks.rst b/content/developer/reference/frontend/hooks.rst index ba240153d..5fd866a4e 100644 --- a/content/developer/reference/frontend/hooks.rst +++ b/content/developer/reference/frontend/hooks.rst @@ -193,18 +193,20 @@ the window is resized/scrolled. .. code-block:: javascript import { usePosition } from "@web/core/position_hook"; + import { Component, xml } from "@odoo/owl"; + + class MyPopover extends Component { + static template = xml` +