Odoo Module Structure

Greetings Everyone,

In this blog-post you will learn about the modular structure of odoo i.e. What a module consists of, its structure and how it is divided.

Take a look at the module and you will find a specific convention followed to create a module. Each file and folder has a unique purpose and you need to follow the file/folder structure to build your module.

Here is the Odoo Module Directory Structure Diagram,

Odoo Module Structure Diagram.
Odoo Module Structure Diagram. Click on the image to enlarge.

Let’s dive in and see what each file/folder stands for:

  1. __init__.py – This file is the initializer of the module. You might have heard about the term ‘constructor’ in java and this file acts in the same way. It contains import statements linking to folders and files in the module.
    For e.g. – import models, import wizard etc.
  2. __openerp__.py – This is the manifest file of the module. It contains various information about your module i.e. Title, Description, Summary etc. You can put some light on the person installing it as why you are building this module, what is the purpose of this module and what your module really does.
  3. models – This folder contains all your python (.py) files. All the python models (in v8 models.Model) that you create or inherit goes into this directory.
    For e.g. – sale.py, crm.py
  4. views – This folder contains all your view (.xml) files. The view file can contain a form, tree, search views, action etc
  5. static – Since Odoo 8, website feature is introduced. This folder is basically used to store website related data. It has a subfolder called src and inside src, there are subfolders like,
    1. src
      1. js – contains .js files
      2. img – contains images
      3. css – stores .css files for designing
      4. xml – used for qweb templates
      5. font – font files.
      6. lib – Used for implementing 3rd party libraries in JS. For e.g. – Combobox library, Google Maps library
    2. description – It contains an index.html file which is used to give a graphical introduction to your module. Moreover, it contains icon.png which is set as the logo of the module.
  6. data – Contains data files (.xml files). Sometimes data needs to be inserted along with the module every time the module is installed. You can specify such data in a data file and place it inside this folder. For e.g. Country, States, Unit of Measures
  7. demo – Contains demo data files (.xml files). This data is useful when you want the user to see a glimpse about how the entries are made in your module. For e.g. Customer invoice, Sale Orders, Quotations. This data is only installed if ‘Load Demo Data’ option is enabled at the time of database creation.
  8. security – This folder is used to give user roles and permissions. The groups/record rules are  defined in an xml file and put in this folder. Moreover, it has ir.model.access.csv file which provides model level security i.e. read, write, create and unlink(delete) permission.
  9. controller – Basically what a controller does is it gets a request from the client and inquires the server. It gets the work done at the server side and returns back to the client. This folder contains python (.py) files.
  10. wizard – This folder contains transient models and their views (.py & .xml files). The data is stored temporarily in this model/table and are vacuumed/deleted at regular interval.
  11. test – Contains .py files to make test cases.
  12. report – This folder consists of report views (.xml) and parser files (.py).
  13. workflow – Used to specify a complete business process.
  14. i18n – means Internationalization, comprises of .po files which are used for translating the text inside your module into several languages. The .po files are named on the basis of the language code. For e.g. – en.po

Hope you learnt about the module structure of odoo, your reviews/comments/suggestions are most welcomed, please comment in the section below, and subscribe to the newsletter to receive timely future updates of this blog.

To learn in-depth about the __init__.py and __openerp__.py  file content, Click Here.

Thank You.

By Burhan Vakharia

Having 6+ years of experience working on Odoo with projects covering several business verticles like Retail industry, Manufacturing, Service, Rental, Education, Medical and many more. I am having experience working on Odoo projects from several countries across the globe.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/odootech/public_html/wp-includes/functions.php on line 4759

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/odootech/public_html/wp-includes/functions.php on line 4759