Odoo Help


Create new module and new table in database

on 3/24/16, 4:19 AM 2,927 views


I can create new module by inheriting other models and fields data saved in existing table but I want to create new module which data will save in new table in database.

can anyone help me or give me a sample model please.

Dr Obx
On 3/24/16, 6:04 AM

To create new module you must:

1. Create a folder in Addons

2. Create __init__.py

3. Create __openerp__.py

4. Create your module.py file

5. Create your module_view.xml file

6. Security folder and inside of this folder ir.model.access.csv where you can put some information about access etc

__init__.py should contain: import your_module/s_name/s


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

import your_module_name

__openerp__.py should contain: a description of your module, dependencies, vews etc



'name': 'Base',

'version': '1.3',

'category': 'Hidden',

'description': """

The kernel of OpenERP, needed for all installation.



'author': 'OpenERP SA',

'maintainer': 'OpenERP SA',

'website': 'http://www.openerp.com',

'depends': [],

'data': [











'demo': [






'test': [



'tests/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.


'installable': True,

'auto_install': True,


your_module_view.xml should contain your_module_view_definition:


<?xml version="1.0" encoding="utf-8"?>



<record model="ir.actions.act_window" id="base.action_res_groups">

<field name="name">Groups</field>

<field name="context">{'search_default_no_share': 1}</field>


<record id="view_groups_form_share" model="ir.ui.view">

<field name="name">res.groups.form</field>

<field name="model">res.groups</field>

<field name="inherit_id" ref="base.view_groups_form"/>

<field name="arch" type="xml">

<field name="users" position="attributes">

<attribute name="context">{'search_default_no_share':1}</attribute>


<field name="name" position="after">

<field name="share"/>






your_module.py should contain:

#class with _columns will create your table with your columns

class your_class(osv.osv):

_name = 'your.class'#your new table

_description = 'Your class description'

_columns = {

'your_field_1': fields.type_of_field('Field name'),

'your_field_2': fields.type_of_field('Field name'),

'your_field_3': fields.type_of_field('Field name'),

'your_field_4': fields.type_of_field('Field name'),


    def your_def(self, cr, uid, args, fields, context=None):#check manual in case you need some special args o kwargs etc

        do something

Of course it's just a basics but .... that's all you need to build your own module. :)

Thank you so much Obx.... I appreciate your help.

on 3/28/16, 5:41 AM

Nice answer @Dr. Obx +1

Ankit H Gandhi(AHG)
on 3/29/16, 7:01 AM

Your'e welcome :)

Dr Obx
on 3/31/16, 8:16 AM

While Dr Obx's answer is pretty thorough, might I point out: 1) it's missing the import statement in your_module.py 2) We should be helping new people learn the new API

Michael Watchorn
on 3/31/16, 12:51 PM

@Anchal: The key to creating a new table is the line: '_name = your.class'.

Michael Watchorn
on 3/31/16, 12:57 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 3/24/16, 4:19 AM
Seen: 2927 times
Last updated: 3/31/16, 8:16 AM