Odoo Help


Creating a new model example?

Dale E. Moore
on 2/7/13, 11:02 AM 8,407 views

Where can I find examples of creating new models (tables) online? Or perhaps I should look in the source code. Do you have any suggestions as to where I should start looking?

I'm especially interested in following the proper method of relating the project model one2many new items.

On 2/7/13, 11:26 AM


Creating Models in OpenERP is a fairly straightforward process, and can be done in two ways, depending on the context.

1) Create a dedicated module for OpenERP that installs your model when the module is installed.
2) Create a new model directly in your OpenERP database using the user interface.

Option 1 is good if you plan on distributing your model to other people. It is also safer because if, for whatever reason, you need to create a new database or want to deploy a second version of OpenERP, all you have to do is re-deploy the module - all your hard work is backed up. Open 1 does, however, require some technical programming knowledge. You also get full access to the OpenERP API and the python programming language.

Option 2 is good if you are the only person who will use the model, and if it is a small, simple project. They are stored directly in the database. It is easier to do, and requires no programming knowledge, however you will be limited to very simple data in / data out functionality. Good for, for example, storing a bunch of text notes with dates etc.

For option 1, there are lots of articles on the web. I would start out by reading the OpenERP module development article. This article describes the anatomy of an OpenERP module, followed by more in-depth usage instructions for each aspect.

For option 2, you can start out by going directly to the Settings > Technical > Database Structure > Models section of OpenERP (version 7) while logged in as the administrator. From there, you can create models like any other record in OpenERP! Don't forget that your model will need a Menu Item so you can manage the records (Notice the handy "Create a Menu" button on the model form view). You might also want to make custom Views to display your records.

Specifically for one2many Documentation for one2many fields can be found here. This will be especially useful if using option 1 (creating a module) but will also help you understand how relational fields are used within OpenERP.

Good luck!

Module development did probably not change much between 6.1 and 7.0, right? Anyway, it would be nice to have the example updated to the latest release, including usage of the new web interface. Is there any complete example for 7.0 available? Thanks in advance!

on 2/24/13, 7:54 PM

You are right - module development has not really changed between 6.1 and 7.0. Nevertheless, I have found this link: http://doc.openerp.com/trunk/developers/server/03_module_dev/ which seems to be a more up to date version of the OpenERP module development article linked above - I have updated my answer.

on 2/25/13, 5:17 AM

I have created the model through code see this http://codeimplementer.blogspot.in/2013/10/how-to-create-new-model-in-existing.html

Dhana Babu
on 10/24/13, 12:36 PM

Is it possible to create a model for existing tables? (sale_order_tax doesn't have)

Marc Wagener
on 10/8/14, 6:48 AM

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

1 follower(s)


Asked: 2/7/13, 11:02 AM
Seen: 8407 times
Last updated: 3/16/15, 8:10 AM