Saturday, 20 August 2016

Odoo Module Structure

Hello Everyone,

Today i am going to guide you about the modular structure of odoo.
for example-what a module consists of, its structure and how it is divided.

Take a look at odoo modules and you will find a specific format/structure 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 custom module.

[ Odoo Module Directory Structure ]

Now let's get the detail information about each file/folder:

  • __init__.py : This file is used to initialize your module and its mandatory in each and every module you create. It contains import statements linking to folders and files in the module.
          for example : 1- Import all files & directories containing python code.
                                2- import models, wizard, report.
  • __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.
  • models : This folder contains all your python (.py) files. All the business logic files, having extension .py
          for example : account.py, sale.py, etc.
  • views : This folder contains all your view (.xml) files. The view file can contain a form, tree, search views, action etc.
  • 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,
    • src : 
      • js – contains .js files
      • img – contains images
      • css – stores .css files for designing
      • xml – used for qweb templates
    • 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.
  • 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
  • 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.
  • 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.
  • 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.
  • 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.
  • test : Contains .py files to make test cases.
  • report : This folder consists of report views (.xml) and parser files (.py).
  • workflow : Used to specify a complete business process.
  • 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

1 comment:

  1. Probably, the biggest advantage of Odoo is its modular design. On the other hand, the community also plays a great part here. Nevertheless, in this post we have shown that Odoo is also popular for its integrating abilities.

    ReplyDelete