Wednesday, 4 June 2014

Open Erp Custom Module Development

Custom Modules/Addons

I am writing on custom openerp module development,This is meant to kick start you development of modules in open erp.It will enable you use the strong features of Object oriented software development.

Few file needs to be created compulsory.
We will take an example let say – “project1_module”

First of all, we will see the architecture of a typical OpenERP module.
Python files
Menu Entries


All the modules are located in server/addons directory.
The following steps are necessary to create a new module “project_module”:

- create a subdirectory in the server/addons directory having module name project_module.
- create a module description file:
- create the Python file containing the objects.
- create .xml files that download the data (views, menu entries, demo data, …).
- optionally create reports, wizards or workflows.

We will see each files introduction one by one.

The file:

The file is, like any Python module, executed at the start of the program. It needs to import the Python files that need to be loaded.
So, if you create a “” file, containing the description of your objects, you have to write one line in


fig a.)
The file

In the created module directory, you must add a file. This file, which must be in Python format, is responsible to
determine the XML files that will be parsed during the initialization of the server, and also to
determine the dependencies of the created module.
This file must contain a Python dictionary with the following values:

"name" : "Project1 Module",
"version" : "1.1",
"author" : "Open",
"category" : "Project Base/Project Base",
"depends" : ["base"],
"init_xml" : [],
"demo_xml" : [],
"update_xml" : ["project_view.xml"],
"installable": True,
"active": True

fig b.)

The file

from osv import osv
from osv import fields

class project_base(osv.osv):
    ”’Project Base Class”’

fig c.)

The project_view.xml file

<?xml version=“1.0 encoding=“utf-8?>
       <record model=“ir.ui.view” id=“project_base_form”>
           <field name=“name”>project.base.form</field>
               <field name=“model”>project.base</field>
               <field name=“type”>form</field>
               <field name=“arch” type=“xml”>
                   <form string=“Project Base”>
                       <field name=“name”/>
                       <field name=“code”/>
        <record model=“ir.ui.view” id=“project_base_tree”>
            <field name=“name”>project.base.tree</field>
            <field name=“model”>project.base</field>
            <field name=“type”>tree</field>
            <field name=“arch” type=“xml”>
                <tree string=“Project Base”>
                    <field name=“name”/>
                    <field name=“code”/>
        <record model=“ir.actions.act_window” id=“action_project_seq”>
            <field name=“name”>Project Base</field>
            <field name=“res_model”>project.base</field>
            <field name=“view_type”>form</field>
            <field name=“view_mode”>tree,form</field>
        <menuitem id=“menu_project_base_main” name=“Project Base”/>
        <menuitem id=“menu_project_base” parent=“menu_project_base_main”
                  name=“Project Base” action=“action_project_seq”/>

fig d.)