Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to get a Python shell with the Odoo environment?

Kasper Souren
on 6/11/14, 10:46 AM 3,791 views

How to get a Python shell with the Odoo environment?

Ideally IPython.

I don't have a clear idea what I want to achieve but over the years I've come to love the possibility of Python (and JavaScript, as opposed to PHP) to just be in a shell with all the relevant code and figure out things. Much better way to learn and code than reading a book or even API documentation.

I started playing around a bit.

    $ ipython

    import openerp


Kasper, may I ask what you want to achieve? `python openerp-server` should do start the server. Have a look at the help for flags / configurations.

Hannes Smit
on 6/17/14, 3:30 AM
Marvin Taboada
On 6/20/14, 1:41 AM

Hello Kasper,

It seems you're using a source distribution where all addons have been moved out of the "openerp.addons" Python package to the root directory of the distribution (current layout in GitHub, branch 7.0), hence it cannot load some required modules. Specifying "--addons-path/addons_path" is required in order to fix this.

You can fake command line arguments in the Python interactive interpreter in the following way:

>>> import sys
>>> import openerp
>>> sys.argv = ['', '--addons-path=/opt/openerp/server/addons', '--log-level=debug']
>>> openerp.cli.main()

Please note that the first argument is an empty string.


Manuel A. Márquez
On 10/4/16, 5:43 PM

I know it's too late but you can use erppeek. https://erppeek.readthedocs.io/en/latest/


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 3/16/15, 5:58 PM

Not compatible with V7, because it's new in saas-6...

But that can help other peoples looking about it...

./odoo.py shell -d saas6

after, all is possible ...


 >>> blog_post_ids = env.registry['blog.post'].search(env.cr, env.uid, [], context=env.context)
>>> env.registry['blog.post'].browse(env.cr, env.uid, blog_post_ids, context=env.context).mapped('name')

[u'The Future of Emails', u'Integrating your CMS and E-Commerce']


>>> env['blog.post'].search([]).mapped('name')

[u'Integrating your CMS and E-Commerce', u'The Future of Emails']

Wouter Tebbens
On 6/19/14, 8:03 AM

Hey Kasper, have a look at this thread, it's precisely about IDE's that people use for OpenERP v7 / odoo development:


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)


Asked: 6/11/14, 10:46 AM
Seen: 3791 times
Last updated: 10/4/16, 5:43 PM