Hello !
I have to access to the ORM of openERP 7 from a python script.
I tried:
>>> import openerp
>>> pool = openerp.pooler.get_pool('test')
No handlers could be found for logger "openerp.modules.module"
>>> my_obj = pool.get('my_obj')
>>> type(my_obj)
<type 'NoneType'>
As you can see, I can't access to custom objects (e.g. tables) from outside. I've listed all the objects in the pool via pool.obj_list(), and it seems that the list is too short, even including official modules that are installed.
So, how can I access to all the objects that represents the tables of my database 'test' ?
Thanks !
PS: I can do stuff via XMLRPC instead, but I would like to use the ORM, because it's faster (already tested it).
EDIT: No one ?
Here's a more detailed example :
import openerp
import sys
sys.path.append("/home/openerp/custom_addons")
import synconfig
DBNAME = "test"
uid = 1
cr = openerp.sql_db.db_connect(DBNAME).cursor()
pool = openerp.pooler.get_pool(DBNAME)
ir_model = pool['ir.model']
data = ir_model.search(cr, uid, [])
print 'data from ir.model: %d' % len(data)
my_object = pool['my.object']
data = my_object.search(cr, uid, [])
print 'data from my.object: %d' % len(data)
Output :
data from ir.model: 334
Traceback (most recent call last):
File "./orm_outside.py", line 20, in <module>
my_object = pool['my.object']
File "/home/openerp/server/openerp/modules/registry.py", line 102, in __getitem__
return self.models[model_name]
KeyError: 'my.object'