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,
Letâ€™s dive in and see what each file/folder stands for:
- __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.
- __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 python models (in v8 models.Model) that you create or inherit goes into this directory.
For e.g. â€“ sale.py, crm.py
- 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,
- js â€“ contains .js files
- img â€“ contains images
- css â€“ stores .css files for designing
- xml â€“ used for qweb templates
- font – font files.
- lib â€“ Used for implementing 3rd party libraries in JS. For e.g. â€“Â Combobox library, Google Maps library
- 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
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.