In Odoo 16, a module represents a discrete unit of functionality. We will begin by understanding the purpose and importance of modules. Each module resides in a dedicated directory and consists of several files and directories that contribute to its functionality.
Mainly an Odoo module is declared by its manifest
All modules must have a python file and a manifest file that are __init__.py file and __manifest__.py file.
We can take a look at the structure.
The Manifest File
The __manifest__.py file serves as the entry point for an Odoo module. It contains vital metadata such as the module’s name, version, description, author information, dependencies, and other configuration options. We will explore the structure and significance of the manifest file and how it influences the behavior of the module.
By mentioning the above details in the __manifest__.py file, our module will be visible in the Odoo App list as below.
We can install our newly created module from the App list.
Models & Data
Models are at the core of Odoo module development. They define the structure of data and provide business logic to manipulate it. We will go through creating models using Python classes and decorators, defining fields, managing relationships between models, applying constraints, and utilizing computed fields.
User Interface with Views
Views are responsible for presenting data to users in various formats, such as forms, lists, trees, kanban boards, and calendars. We will explore different types of views and understand how to create and customize them using XML templates. Additionally, we will cover the usage of widgets to enhance the user experience.
In odoo, Tree View also known as List View shows multiple records in the form of a list (rows and columns). Each row represents a record of the database table. You can do various operations on Tree view that are sorting, filtering, and group by. All views are stored in the database.
When you click on New Button in Tree View , you are able to create a New Record as below.
Form views are used to display the data from a single record. It is used to create and edit single records. This is the default form view. Here we can see the field to add name, picture and other details.
Menu for Students details can be seen here.
Access Control & Security
Ensuring data security is crucial in any ERP system. We will discuss how to implement security rules to restrict access to module data and functionality based on user roles and groups. We will also explore techniques to secure sensitive data and maintain data integrity.
Handling Module Data
Odoo allows the provision of initial data for modules using data files. We will explore how to define and manage data files in XML format to seed the database with default records. Additionally, we will discuss managing dependencies between modules and controlling their installation order.
Testing and Debugging
To ensure the reliability and quality of module development, we will cover testing and debugging techniques. We will explore writing unit tests for different components of the module and utilizing Odoo’s logging and debugging tools for efficient troubleshooting.