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:
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:
__openerp.py__: In this file we will write all the description of our modules and its properties. Lets discuss each field in detail.
- 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.
- 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']'.
- 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.
6 Comments
What software editor recommend to programming odoo?
ReplyDeleteHello NN, you can use any editor for odoo programming like(notpad++, eclipse etc) but for simplicity my recommendation is to use sublime text editor.
DeleteThat's clear explanations of odoo modules structure. Thanks SB !!!1
ReplyDeleteI am always there for you my bro :)
DeleteGreat explanation
ReplyDeleteThanks
Delete