documentation/wowl_markdown_doc/registries
Géry Debongnie eff7c05465 [DOC] add master-wowl doc (UNFINISHED)
I know, the doc is still in md, it was only temporary. we will convert
it to rst someday
2021-05-31 15:29:27 +02:00
..
readme.md [DOC] add master-wowl doc (UNFINISHED) 2021-05-31 15:29:27 +02:00
user_menu.md [DOC] add master-wowl doc (UNFINISHED) 2021-05-31 15:29:27 +02:00

Registries

Overview

The Odoo web client provides many registries, which allow developers to extend the web client in a safe and structured way.

Here is a list of all registries:

Name Description
actions definition of all available client actions
Components components (class) that will be instantiated at root of web client
errorDialogs dialogs (class) that will be instantiated by the crash manager to handle errors
services definition of all services that will be deployed
systray components (class) that will be display in the systray menu (a part of the navbar)
views definition of all available views
userMenu definition of all user menu items

Usage

A registry is an owl EventBus with some additional methods (below T is the type of values to be found in the registry):

  • add: (key: string, value: T, force: boolean = false) => Registry<T>: add an entry (key, value) to the registry. By default, add a key already used results in an error. This can be prevented by using the parameter force, leading to the replacement of the old entry. The add method returns the registry itself to allow chaining.
  • get: (key: string) => T: returns a value from the registry. An error is thrown in case the key cannot be found in the registry.
  • contains: (key: string) => boolean: allow to check the presence of a key in the registry.
  • getAll: () => T[]: returns the registry values.
  • getEntries: () => [string, T][] : returns the registry entries.
  • remove: (key: string): remove an entry from the registry.

Each time an item is added (deleted) via add (resp. delete), an event "UPDATE" is triggered with a payload of type

interface Payload {
    operation: "add" | "delete";
    key: string;
    value: T;
}