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.
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.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 2/7/13, 11:02 AM|
|Seen: 6094 times|
|Last updated: 3/16/15, 8:10 AM|