도움말

0

Module create new model - no table create

Avatar
Bole

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??

5 의견
아바타
작성취소
Avatar
Andreas Brueckl
-

Have you updated the module list and installed the module?

Avatar
Bole
-

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

Avatar
Juanjo Algaz
-

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

Avatar
Bole
-

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

9 답변
2
Avatar
Andreas Brueckl
최고의 답변

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.

3 의견
아바타
작성취소
Avatar
Bole
-

jup.. works after restarting server...

Avatar
Bole
-

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

Avatar
Kelly Stuart
-

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