Enable Dark Mode!
scaffolding-odoo-13.png
By: Vinaya Suresh

How to Scaffold a module in Odoo 13

Technical Odoo 13

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 blog let us see how to use scaffolding in Odoo development.


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:


./odoo-bin scaffold module_name folder_name


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.


scaffolding-odoo-13-cybrosys


The expanded structure of the module is shown below:


scaffolding-odoo-13-cybrosys


module_name/__manifest__.py


scaffolding-odoo-13-cybrosys


module_name/models/models.py


scaffolding-odoo-13-cybrosys


module_name/controllers/controllers.py


scaffolding-odoo-13-cybrosys


module_name/demo/demo.xml


scaffolding-odoo-13-cybrosys


module_name/security/ir.model.access.csv


scaffolding-odoo-13-cybrosys


module_name/views/templates.xml


scaffolding-odoo-13-cybrosys


module_name/views/views.xml


<odoo>
  <data>
<!-- explicit list view definition -->
<!--
<record model="ir.ui.view" id="module_name.list">
  <field name="name">module_name list</field>
  <field name="model">module_name.module_name</field>
  <field name="arch" type="xml">
    <tree>
      <field name="name"/>
      <field name="value"/>
      <field name="value2"/>
    </tree>
  </field>
</record>
-->
<!-- actions opening views on models -->
<!--
<record model="ir.actions.act_window" id="module_name.action_window">
  <field name="name">module_name window</field>
  <field name="res_model">module_name.module_name</field>
  <field name="view_mode">tree,form</field>
</record>
-->
<!-- server action to the one above -->
<!--
<record model="ir.actions.server" id="module_name.action_server">
  <field name="name">module_name server</field>
  <field name="model_id" ref="model_module_name_module_name"/>
  <field name="state">code</field>
  <field name="code">
    action = {
      "type": "ir.actions.act_window",
      "view_mode": "tree,form",
      "res_model": self._name,
    }
  </field>
</record>
-->
<!-- Top menu item -->
<!--
<menuitem name="module_name" id="module_name.menu_root"/>
-->
<!-- menu categories -->
<!--
<menuitem name="Menu 1" id="module_name.menu_1" parent="module_name.menu_root"/>
<menuitem name="Menu 2" id="module_name.menu_2" parent="module_name.menu_root"/>
-->
<!-- actions -->
<!--
<menuitem name="List" id="module_name.menu_1_list" parent="module_name.menu_1"
          action="module_name.action_window"/>
<menuitem name="Server to list" id="module_name" parent="module_name.menu_2"
          action="module_name.action_server"/>
-->
  </data>
</odoo>


If you use scaffolding you need not worry about the other files, 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 example, 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. In short, we can say that controllers are used for configuring front-end modules.


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



0
Comments



Leave a comment

 


whatsapp_icon
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