Organizing the addon module file structure
An addon module contains code files and other assets such as XML files and images. For most of these files, we are free to choose where to place them inside the module directory.
However, Odoo uses some conventions on the module structure, so it is advisable to follow them.
Getting ready
We are expected to have an addon module directory with only the __init__.py
and __openerp__.py
files.
How to do it…
To create the basic skeleton for the addon module:
- Create the directories for code files:
$ cd path/to/my-module $ mkdir models $ touch models/__init__.py $ mkdir controllers $ touch controllers/__init__.py $ mkdir views $ mkdir security $ mkdir data $ mkdir demo $ mkdir i18n $ mkdir -p static/description
- Edit the module's top
__init__.py
file so that the code in subdirectories is loaded:# -*- coding: utf-8 -*- from . import models from . import controllers
This should get us started with a structure containing the most used directories, similar...