Minimal openerp module example

Let’s create first minimal dev module. Example will be for Linux and OpenERP 6.1 rc version.

1. Create dev directory in addons:

 mkdir addons/dev

2. Create needed files:

touch addons/dev/dev.py
touch addons/dev/dev_view.xml
touch addons/dev/__init__.py
touch addons/dev/__openerp__.py

3. Update dev.py with code:

# -*- coding: utf-8 -*-
from osv import fields, osv

class dev_person(osv.osv):
    _name = "dev.person"
    _description = "Person"
    _columns = {
        'person_name': fields.char('Name', size=128, required=True, help=""),
    }

dev_person()

4. Update dev_view.xml with code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.actions.act_window" id="action_dev_person_form">
<field name="name">dev_person</field>
<field name="res_model">dev.person</field>
</record>

<menuitem name="Dev" icon="terp-project" id="dev_menu" />
<menuitem name="Person" parent="dev_menu" id="dev_menu_person" action="action_dev_person_form" />
</data>
</openerp>

5. Update __init__.py with code:

# -*- coding: utf-8 -*-
import dev

6. Update __openerp__.py with code:

# -*- coding: utf-8 -*-

{
    "name" : "Dev module",
    "version" : "0.1",
    "author" : "Dev",
    'complexity': "easy",
    "description" : """
    """,
    "website" : "http://www.openerp.com",
    "depends" : [],
    "category" : "Dev",
    "sequence": 16,
    "init_xml" : [],
    "demo_xml" : [],
    "update_xml" : ["dev_view.xml",],
    'test': [],
    'installable': True,
    'application': True,
    'active': False,
}

Reload server. And try to install new module. That’s it!

2 thoughts on “Minimal openerp module example

  1. Hi , i have a lil problem . When i put the “dev” folder in /usr/share/pyshared/openerp/addons/ and i restart(reload) openerp server and update the module list, the module “dev” doesn’t show up . Please could you help me with that ? Thanks

Leave a comment