Search Here

Odoo Module Structure [Terminology]

In my previous post you learned how to create database in Odoo. In this article you will learn about Odoo Modules and its structure.

Understand Odoo Module Structure

Odoo modules can either add brand new business logic to an Odoo system, or alter and extend existing business logic: a module can be created to add your country's accounting rules to Odoo's generic accounting support, while the next module adds support for real-time visualisation of a bus fleet.

In other words: "Everything in Odoo thus starts and ends with modules."

Local Modules

Local modules are those; which are placed in addons directory at local machine. When you install a module it will also install its dependencies. An Odoo modules contain a number of elements:

Understanding Odoo Module Structure - Learn OpenERP

 

Business Object / Models: Declared as python classes. (for example models.py) | Models

__init.py__: In this file we have to write name of all folder and python files which are to be complied to this module. If any directory or python files is not listed in this file, than those file will be ignored which could result in fatal error. This file is use as the manifest file for any python module its kind of entry point of the python module. (add the entry point of the xyz.py file)

Recommend:

Understanding Odoo Module Structure - init py - Learn OpenERP



__openerp.py__: In this file we will write all the description of our modules and its properties. Lets discuss each field in detail.

Understanding Odoo Module Structure - openerp py - Learn OpenERP



  1. Name, description, version, author and category are used to describe our modules and its version. So each time we make changes  we will increase the version number.
  2. Depends: If our module depend on another modules than we specify that module name in depend. For example if our module depends on this "module_name" we will specify 'depends:['module_name']'.
  3. Data:  Here we specify all of our xml files.

Data Files: XML or CSV files (for example xyz.xml). | Views

Module data is declared via data files, xml file with <record> element.

<openerp>
<data>
<record model="{model name}" id="{record identifier}">
<field name="{a field name}">{a value}</field>
</record>
</data>
<openerp>
         In the above code "model" is the name of Odoo model for the record, "id" is external identifier  it allows referring to the record. And the field element have "name" attribute which is the name of the field in the model.

 

Controllers: Handles request from web browsers. (for example controllers.py) | Controller

Understanding Odoo Module Structure - controller py - Learn OpenERP

Static Data: Css, Javascript and images files. 

Reports: Qweb report templates, to be merged with any kind of business data and generate HTML or PDF reports. 

Understanding Odoo Module Structure - report template py - Learn OpenERP

 

Today you learned what is "Odoo Modules" and its component in detail. In my next post you will learn how to create modules in Odoo.

Post a Comment

6 Comments

  1. What software editor recommend to programming odoo?

    ReplyDelete
    Replies
    1. Hello NN, you can use any editor for odoo programming like(notpad++, eclipse etc) but for simplicity my recommendation is to use sublime text editor.

      Delete
  2. That's clear explanations of odoo modules structure. Thanks SB !!!1

    ReplyDelete
  3. Great explanation

    ReplyDelete