How do I import an Odoo/OpenERP addon module from a python shell?
I want to learn more about the structure of Odoo. I prefer to do that through IPython, but I'm not sure how to import addons into the environment. For starts I merely want to load a default Addon into my environment. So I just copied a line from the default Product module. I did not modify anything in the source code. I have been grepping through the source code to find out why I can't simply import the Addon in the I'm used to with Python.
My Odoo installation works fine.
$ cd /opt/odoo
$ ipython
In [1]: import openerp
In [2]: openerp.modules.module?
[not much luck]
In [3]: openerp.addons?
[not much luck either, nothing here either]
In [4]: import openerp.addons
[no error]
In [5]: import openerp.addons.decimal_precision as dp # Line from addons/product/product.py
[....]
ImportError: No module named decimal_precision
openerp.addons
doesn't have anything but still import openerp.addons.STUFF
works fine from Odoo addon modules.
I have the feeling that addons
needs to be initialized but I haven't found out how to do that. I started going through the code from openerp.main.cli()
.
openerp.tools.config.parse_config()
is a step in the right direction but it's not enough. I need to somehow pass --addons-path=addons
as well (since Odoo is not smart enough to find its own addons).