Enable Dark Mode!
how-to-import-registries-in-odoo-15.jpg
By: Sonu S

How to Import Registries in Odoo 15

Technical Odoo 15

The registries are ordered by value or keymap. It is the main web-client extension point. Many of the functions provided by the Odoo Javascript framework simply search the registry when you need to define objects (fields, views, client actions, services, etc.). Web client customization is as easy as adding specific values to the correct registry.
The example for importing the registries is as follows:
import { registry } from "@web/core/registry";
const registry = new Registry();
registry.add("foo1", false);
registry.add("foo2", 0);
registry.add("foo3", "");
A useful feature of registries is to keep a set of sub-registries obtained in a 'category' manner. If the sub-registries do not already exist, they will be created on the startup. Therefore, all registries used by web clients are taken from the root registry and exported to @web/core/registry.
import { registry } from "@web/core/registry";
const fieldRegistry = registry.category("fields");
const serviceRegistry = registry.category("services");
const viewRegistry = registry.category("views");
Category of registries
1. Effect registry
The effects registry contains a framework of all available effects. You can add new effects by specifying a name and function. The example for the rainbow man effect is as follows:
const effectRegistry = registry.category("effects");
effectRegistry.add("rainbow_man", rainbowMan);
2. Formatter registry
The formatter registry contains functions for formatting values. Each formatter has the following APIs:
format (value [, options])
3. Main components registry
The main component registry (main_components) helps you add top-level components to your web client. The web client has a direct child, MainComponentsContainer. This component essentially represents a live representation of an ordered list of registered components in the main component registry.
For example, the BlockUI component can be added to the registry like this:
registry.category("main_components").add("BlockUI", BlockUiFromRegistry);	
4. Parser registry
The parser registry contains functions for parsing values. Each parser has the following APIs- value (string)-String representing the value, Options (object)-Various options (parser specific):
parse(value[, options])
5. Service registry
The service registry (category: services) contains all the services that need to be activated by the Odoo framework.
registry.category("services").add("myService", myService);
6. Systray registry
Systray is the area to the right of the navigation bar. Usually, it contains information (e.g., the number of unread messages), notifications, and various minor components with which the user can interact.
7. User menu registry
The user menu registry (category: user_menuitems) contains all the menu items that are displayed when you open the user menu (navigation bar items with username in the upper right corner).
The effects registry contains a framework of all available effects. You can add new effects by specifying a name and function. The example for the rainbow man effect is as follows:
const effectRegistry = registry.category("effects");
effectRegistry.add("rainbow_man", rainbowMan);
Conclusion:
The registry is the main extension point for the web client. Many of the features provided by the Odoo JavaScript framework only require access to the registry whenever a definition for some object is needed.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment

 


whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message