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
In : import openerp
In : openerp.modules.module?
[not much luck]
In : openerp.addons?
[not much luck either, nothing here either]
In : import openerp.addons
In : import openerp.addons.decimal_precision as dp # Line from addons/product/product.py
ImportError: No module named decimal_precision
My advice is for you to use the Odoo
$ ./odoo.py shell -d <your_db>
You will get an interactive shell with
self available as if you were inside a model method, although in plain Python rather than IPython.
It is available in 9.0, and has a community backport for 8.0.
Another alternative is to use ERPPeek: it is a Python client, connecting to a remote Odoo server, that can run interactive commands similar to (but not the same as) the ones used in the server. An advantage of this is that you don't need Odoo installed on your side, and can choose to run ERPPeek with the Python version you prefer.