ERPpeek, a tool for browsing OpenERP data from the command line

We have been rather busy implementing OpenERP for a number of our customers and I have been tweaking and customising and extending it all over the place. It is a great fun product to work with, very flexible and Python is a really nice language to use. One thing I have been finding is that as a developer I really want to know more about the fieldnames and field values that are stored behind the scenes on an object, I want a command line utility to allow me to inspect a particular document and figure out why it displays what it displays etc. There might be one out there somewhere, but I figured it would be more fun to write my own, so I did. The best way to show how it works is with an example

./erppeek.py -d testdb -u admin -p admin -m res.users 1

in it’s simplist form that will connect to an openerp server running on localhost, (port 8069) with username admin and password admin to a database called testdb. It will then return all fields for the model res.users with id 1 (which will be the admin user)

./erppeek.py --server 'http://myserver.com:8069' -d testdb -u admin -p admin -m res.partner 1 3 5

This connects to a remote server called myserver.com and returns all fields from partners 1, 3 and 5

./erppeek.py --server 'http://myserver.com:8069' -d testdb -u admin -p admin -m res.partner -f name -f city 1 3 5

and now we are using the -f field parameter to return just the name and city (and it always returns the id as well) of those partners

./erppeek.py --server 'http://myserver.com:8069' -d testdb -u admin -p admin -m res.partner -f name -f city -s "name like School" -s "city = Southampton"

This time it is not relying on us passing in a list of object IDs, but it is doing a search of the res.partner objects where the name field contains ‘School’ and the city field is equal to Southampton.

To grab a copy of this small but handy little utility please download it from launchpad and make it executable. It works fine on Ubuntu, and should work on most platforms with Python. Do let me know in the comments what you think of it and what else you would like it to do.

Security note – this does at the moment get you to enter a password on the command line, which means the password will be available in your bash history and other users on your computer looking at processes you are running. This doesn’t bother me much as I am only using it on local development databases with trivial passwords anyway, but you have been warned. If someone wants to help fix that then great.

Tags:

10 Comments

Leave a Reply to Frontware International

XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>