Scaffolding is the way of building a skeleton structure for a module in Odoo. Using Odoo scaffolding we can create the module structure automatically. It saves much of our effort in creating a module manually. This slide lets us see how to use scaffolding in Odoo development.
2. INTRODUCTION
Scaffolding is the way of building a skeleton structure for a module in Odoo. Using Odoo
scaffolding we can create the module structure automatically. It saves much of our effort in
creating a module manually. In this slide let us see how to use scaffolding in Odoo
development.
3. ❖ In usual cases, a module is a directory within a module directory. The module path is specified
in addons_path.First of all, you can create a new module say for example custom_addons in
/opt/odoo/custom_addons.In order to build a module structure, first of all, we have to navigate
to the odoo-bin path via terminal.Enter the below command to automatically create a module
structure:
4. In the previous command,
➢ Module_name: Name of your module
➢ folder_name: Name of the directory inside which you need to create the module.
➱ Execution of the above command provides the following output.
6. ❖ Each module contains required python files, they are ‘__init__.py’ and ‘__manifest__.py’
file.
❖ __init__.py
In the __init__.py file, we have to import all the python files that we are going to use. Suppose
as described above we have a python file called model.py in our module. The first thing we
have to do is, import the model.py in the __init__.py file.So the __init__.py file will be like this,
7. __manifest__.py
In the __manifest__.py, We have to mention the module name, the author name,
version, description, company, category, etc. Now let us see what all these things
for,
* Name – Name of the module to be displayed.
Version – version of the released module.
* Summary – Summary for the module.
* Category – Category of the module, whether it is sales, purchase, the point of sale
etc.
8. * depends – Suppose if our module depends on any other modules, we have to
mention that name in the depends. As we are going to create a new module and as
it is not depending on any other modules, just add depends as the base.
* data – In the data section, we have to specify all the .xml files here. In our case,
we have to mention the view.xml
9. ❖ So our __manifest__.py file will be like this,
10. ❖ And Other Folders in the module is,
➢ module_name/models/models.py
16. ❖ Here, everything will be created automatically. You can edit the contents as required.
1. Models consist of all the python files.
2. Views are used to define the way the record has to be displayed.
3. Data files consist of demo data that are needed in a module. It consists of XML
elements that create/update database records.
4. Security file helps you to configure access rights.
5. __init__.py file is used to import the python files defined in the module.
6. Controllers are used in cases where we need to render data to the website. For eg, if
we need to display the sale order details in the website the functionality of models are not
enough. In such cases, you need to integrate frontend modules to the backend. So, we
can say that controllers are used for configuring front-end modules.
17. For More
Details
Check our company website for related blogs and Odoo
book.
Odoo Book V15
Check our YouTube channel for functional and technical
videos in Odoo.
Building a Module in Odoo 15 Scaffold Method