Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. 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
    
  2. 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 to this...