One year ago, much for the fun, I started a small open source project OOOR - OpenObject on Rails: the idea was to explore Ruby metaprogramming techniques to remotely access the whole API of OpenERP using the standard OpenERP webservices just like the genuine Rails ActiveResource API. The thing is that OOOR is more and more being used for awesome stuff today, so I think it was the right time to finally present it to the general public…
introducing OOOR - OpenObject On Rails
BY |
Hello, one year ago, much for the fun, I started a small open source project OOOR - OpenObject on Rails: the idea was to explore Ruby metaprogramming techniques to remotely access the whole API of OpenERP using the standard OpenERP webservices. The thing is that OOOR is more and more being used for awesome stuff today, so I think it was the right time to finally present it to the general public.
As an OpenERP integrator/admin/advanced user, you’ll soon discover:
- how OOOR is backing the most promising OpenERP functional non regression test suite OERPScenario led by CampToCamp.
- how OOOR can be used to administrate your OpenERP server(s), to help migration…
- how OOOR can be used in in one of the topmost open source ETL, Kettle to really turn OpenERP data integration a trainee job instead of an advanced programmer job.
- how OOOR can draw OpenERP UML diagrams using the whole object model and not just the database, like it has never been done before.
- how OOOR can expose OpenERP object Restfully in HTML, XML and JSON formats.
- how OOOR could eventually be a future OpenERP full blown web client, or at least a life saver if you are stuck of the current widgets.
- how OOOR can connect your new awesome Rails website to OpenERP
- how OOOR can give you access to OpenERP from Java via JRuby.
But for now, I’ll just give you a quick overview of OOOR. So OOOR is small Ruby package, a “gem”, that is less than 500 lines of code. Don’t worry, the Ruby language is probably the closest cousin of the Python language. Chances are that learning a bit of Ruby will make you smarter so don’t hesitate to jump in. Finally, you’ll need to know only a very small part of Ruby to use OOOR, just the basic syntax, calling methods on objects, iterating over a table, putting a value in a map and you are done. If you don’t know Ruby, take 15 minutes to http://tryruby.org. This is really all it takes for what you’ll need with OOOR.
Installing OOOR:
install the Ruby language, its ‘irb’ command line interpreter, and its standard packaging tool ‘Rubygems’. On Ubuntu/Debian for instance, this is as simple as:
>sudo apt-get install ruby irb rubygems
now make sure your rubygems package is aware of the ‘gemcutter’ gem repository with:
>sudo gem tumble
Now install OOOR automagically:
>sudo gem install ooor #last version so far is 1.2.3
Playing with OOOR:
start an OpenERP server with a demo data database with XML/RPC on port 8069 (default settings), then open an irb session
A few characteristics:
- OOOR tries to ‘fix’ the OpenERP ORM awkward API:
- So instead of accessing the persistence with Class Methods only like in OpenERP (you know the self.pool.get(‘my.resource’).write(cr, uid, [id_of_my_current_object], my_value_hash), well you just do in OOOR: my_entity.update after you changed some values eventually. This is much easier to learn for the occasional coder/functional consultant needing to get his hands dirty.
- you would also just to p.taxes_id = [1,2]; p.save rather than self.pool.get(‘product.product’).write(cr, uid, [my_id], {taxes_id : [6, 0, [1,2]]}) in OpenERP and the same goes for one2many relations
- OOOR supports Create, Read, Update, Delete (CRUD) operations but also any OpenERP expose business object methods, including:
- button clicks
- on_change events
- workflows
- wizards you get the full detail on the project page here
- In any case, the API of OOOR is not an accident. It’s actually a careful respect of the the standard exemplar Rails ActiveResource API, extended with relations supports and domain + context support to exactly match the OpenERP API itself.
- OOOR doesn’t connect to the database directly, it enforces the OpenERP layer encapsulation, object models and custom access rights.
- OOOR supports connecting to several OpenERP instances at the same time, using a scoping prefix in the front of its class names, very handy to migrate data from one instance to an other, see: http://wiki.github.com/rvalyi/ooor/howto-connect-ooor-to-multiple-openerp-instance-easy-data-migration
- OOOR is 100% compatible with JRuby, meaning you can use it from Java and you’ll see how in my next post about its usage in the famous Kettle ETL (Pentaho Data Integration).
- OOOR can also expose your OpenERP entities Restfully to other consumers using standard Rails support for REST, for that you should install the [‘OooREST’ extra gem
- ever wonder how OpenERP could have such a bug and always thought that its current unit test framework has its limits when it comes to testing full real life functional/cross modules scenarios? Well in that case you should give a look to the “Cucumber” testing framework. Now, the dream comes true, CampToCamp just rolled a version of it for OpenERP, using OOOR to drive/query OpenERP. If you are willing to help making OpenERP a more robust system or if you want to package some tests with your OpenERP custom module to always be able to tell exactly and deterministically what works and what is broken, I totally encourage to you to jump in OERPScenario led by CampToCamp. By the way, OERPScenario is also able to play the OpenERP built’in unit test suite now, so it does just more and not less. Seriously, did you see something better than Cucumber/RSpec for testing? Me never, and I can tell you than when I worked 6 months on airline GDS testing at Amadeus before, I would have loved have something approaching Cucumber/RSpec, so having it for your ERP is totally awesome.
All right, I hope it provided you an insight of the OOOR unleashed power. If you need more, Akretion is willing to provide professional support to OOOR, but in any case we are committed to OOOR as a community open source (MIT liberal license) project. In a next post, I’ll show you how you a noob programmer can easily pull/push any complex data form/to OpenERP using the Kettle ETL + OOOR embedded as a step plugin. We are already using it for customer projects at Akretion and it’s a life saver.