Odoo – Create first module

Module Structure

An Odoo module consists of some basic elements. Note that what is explained here is only the basic files required to develop a module and structure will be more complex in actual real world applications.

__init__.py – init script will load the application’s main python-module and related in application initialization.

__openerp__.py – is the module descriptor file.

module_name.py – a class, contains the application logic and database table structure definition.

view_name.xml – contains the application interface definition and menu structure.

First Create a new folder in addons directory of server as “book” and add following files.

There is no specific order, I am going to start with the main python class (module) of our Odoo module. This will handle the core functionality of the module and also will generate the database table to store related data.


import book


‘name’ : ‘Book Module’,
‘version’ : ‘1.0’,
‘author’ : ‘ananthu’,
‘website’ : ‘http://www.odoo.com’,
‘category’ : ‘Tools’,
‘depends’ : [‘base’],
‘description’ : ‘Book Simple demo module’,
‘update_xml’ : [‘book_view.xml’],
‘installable’: True


<?xml version=”1.0″ encoding=”utf-8″?>
<record model=”ir.ui.view” id=”book_tree_view”>
<field name=”name”>book.tree</field>
<field name=”model”>book.book</field>
<field name=”type”>tree</field>
<field name=”arch” type=”xml”>
<tree string=”Book”>
<field name=”title”/>
<field name=”desc”/>
<field name=”author”/>

<record model=”ir.ui.view” id=”book_form_view”>
<field name=”name”>book.form</field>
<field name=”model”>book.book</field>
<field name=”type”>form</field>
<field name=”arch” type=”xml”>
<form string=”Book”>
<field name=”title”/>
<field name=”desc”/>
<field name=”author”/>

<record model=”ir.actions.act_window” id=”action_book_form”>
<field name=”name”>book</field>
<field name=”res_model”>book.book</field>

<menuitem name=”Book” id=”book_menu”/>

<menuitem name=”Book Group” id=”book_group_menu” parent=”book_menu”/>

<menuitem name=”Books” parent=”book_group_menu” id=”book_menu_mainform” action=”action_book_form”/>


from openerp.osv import fields, osv
from openerp.http import request

class book(osv.osv):
_name = “book.book”
_description = “Simple Book”
_columns = {
‘title’ : fields.char(‘Title’, required=True),
‘desc’ : fields.text(‘Description’),
‘author’ : fields.char(‘Author’, required=True),





Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s