Odoo Help

Welcome!

This community 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.

0

Module create new model - no table create

By
Bole
on 2/20/13, 6:01 AM 5,659 views

I'm trying to learn OpenERp code logic... I would like to write a new module, and need a new model created..

This is res_certificates.py code

from openerp.osv import fields, osv, orm
class res_certificates(osv.Model):
    _name='res_certificates'
    _description='Stored Certificates'
    _order='name'
    _columns = {
        'name': fields.char('Name', size=128, help="Internal name for certificate", reguired=True, select=True),
        'cert': fields.text('Certificate', help='Certificate (text)') ,
        'cert_password': fields.char('Certificate Password', size=64),
        'cert_key': fields.text('Private Key', help="Private key for user"),
        'key_password':fields.char('Private Key Password', size=64)

        }

res_certificates()

called from __init__.py as

import res_certificates

does not create any table table (note: at the moment i just need the table. no views) working on v7.0

If anyone could tell me what am i missing here??

Have you updated the module list and installed the module?

Andreas Brueckl
on 2/20/13, 6:30 AM

yes, modude is visible in the list, and install returns : openerp.modules.loading: module my_module: loading objects

Bole
on 2/20/13, 6:31 AM

can you try class res_certificates(osv.osv): ?

Juanjo Algaz
on 2/20/13, 6:52 AM

yes.. tried it olso.. but.. it should be the same.. because... in openerp.osv.osv lines 211-214 states: "# deprecated - for backward compatibility. osv = Model osv_memory = TransientModel osv_abstract = AbstractModel # ;-)"

Bole
on 2/20/13, 6:58 AM
2

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 2/20/13, 6:53 AM

Replace

_name='res_certificates'

with

_name='res.certificates'

Then restart and update the module again.

Here is the link to the Documentation of objects, fields and methods. However there is dedicated section for naming conventions.

jup.. works after restarting server...

Bole
on 2/20/13, 7:03 AM

would appriciate some usefull link on naming conventon here, because i saw in some modules naming _name='res_certificates' works fine???

Bole
on 2/20/13, 7:04 AM

The ORM converts the . to _ for you automatically when it names the new table.

Kelly Stuart
on 11/22/14, 2:17 AM

Your Answer

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

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/20/13, 6:01 AM
Seen: 5659 times
Last updated: 3/16/15, 8:10 AM