Odoo is a comprehensive business management software encompassing various modules designed to streamline and integrate different aspects of business operations. Each module in Odoo corresponds to a specific business function, providing a modular and scalable approach to managing various processes.
The structure of an Odoo 17 module is crucial for its proper functioning. Let's break down the key components of a module.
1.__init__.py: Module Initializer
The __init__.py file serves as the module initializer. It is responsible for importing the necessary packages or files needed for Odoo and potentially executing custom code during module initialization.
Eg :
from . import models
from . import controllers
2.__manifest__.py: Metadata Definition
The __manifest__.py file contains metadata about the module. Here's a snippet from our example:
{
'name': 'Module Name',
'version': '1.0',
'summary': """Summary of the Module""",
'description': """Description of the Module""",
'category': 'product',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'depends': ['base'],
'website': 'https://www.cybrosys.com',
'data': [
'security/ir.model.access.csv',
'views/filename.xml',
‘data/filename.xml',
],
'assets': {
'web.assets_backend': [
'module_name/static/src/js/*.js',
'module_name/static/src/css/*.css',
'module_name/static/src/img/*',
],
},
'images': [],
'license': 'OPL-1',
'price': 9.99,
'currency': 'EUR',
'installable': True,
'auto_install': False,
'application': False,
}
* Name: Name of the module
* Version: Module version
* Summary: A summary or one-liner describing the module.
* Description: A more detailed description of the module.
* Category: The category under which the module is classified.
* Author: The name of the author or creator of the module.
* Website: The URL of the website related to the module.
* Depends: A list of other Odoo modules that this module depends on.
* Data: A list of file paths to XML or CSV files containing data definitions or configurations for the module.
* Images: A list of image paths or binary image data representing the module.
* license: The license under which the module is distributed.
* Price: The price of the module, if applicable.
* Assets: To define static files related to the backend (admin interface). The 'web.assets_backend' key specifies the type of asset, and the list underneath enumerates the paths to the respective JavaScript files, CSS files, and images within the module.
* Currency: The currency in which the price is specified.
* Installable: Specifies if the module can be installed from the Web UI.
* Application: Indicates whether the module is an app or not.
3. Module Components:
Models: Contains all Python files for the module (e.g., sale_order.py).
Views: Holds XML files for user interfaces like kanban, list, form, tree, menu, etc. (e.g., sale_order.xml).
Static: Consists of public assets such as JavaScript, CSS files, images, etc., accessed without authentication. These files reside in the src directory.
Wizard: Contains files related to the wizard functionality.
Data: Includes data files and the module's initial data.
Demo: Holds demo data for testing, training, or evaluation.
i18n: Contains .po and .pot files for translations.
Security: Consists of XML files defining access rights, groups, and record rules (e.g., ir.model.access.csv).
Controllers: Contains files providing functionality to website controllers.
Understanding and adhering to this module structure ensures a standardized approach to Odoo development and facilitates collaboration and scalability in managing diverse business processes. Whether you're a developer creating custom modules or a user implementing existing ones, a clear grasp of this structure enhances the overall efficiency and effectiveness of Odoo as a business management solution.
To read more about the overview of the Odoo 16 module structure, refer to our blog An Overview of Odoo 16 Module Structure