This question has been flagged
9 Replies
19619 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??

Avatar
Discard

Have you updated the module list and installed the module?

Author

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

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

Author

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 # ;-)"

Best Answer

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.

Avatar
Discard
Author

jup.. works after restarting server...

Author

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

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