OOOREST - OpenObject On Rails, REST layer

BY OOOR stands for OpenObject On Rails. OpenObject is the RAD framework behind OpenERP, the ERP that doesn't hurt, just like Rails is "web development that doesn't hurt". So OOOR exposes seamlessly your OpenOpbject application, to your custom Rails application. Needless to say, OOOR doubly doesn't hurt. Furthermore, OOOR only depends on the "activeresource" gem. So it can even be used in any (J)Ruby application without Rails.

OooREST enables REST HTTP routes to your OpenERP models: Before anything, make sure you read the doc of OOOR Install the gem using gem install ooorest.

we assume you created a working Rails application, in your config/environment.rb Inside the Rails::Initializer.run do |config| statement, paste the following gem dependency (along with the ooor dependency):

$ config.gem "ooorest"

in your config/route.rb, you can alternatively enable routes to all your OpenERP models by addding: $ OOOREST.load_all_controllers(map)

Or only enable the route to some specific model instead (here partners): $ map.resources :res_partner

REST HTTP API:

$ http://localhost:3000/res_partner
$ http://localhost:3000/res_partner.xml
$ http://localhost:3000/res_partner.json
$ http://localhost:3000/res_partner/2
$ http://localhost:3000/res_partner/2.json
$ http://localhost:3000/res_partner/2.xml
$ http://localhost:3000/res_partner/[2,3,4].xml
$ http://localhost:3000/res_partner/[2,3,4].json

$ TODO http://localhost:3000/res_partner.xml?active=1

$ TODO http://localhost:3000/res_partner.xml?domain=TODO

FAQ

Can I extend the OOOR controllers?

Yes, you can do that, see the "how to extends models" section as it's very similar. Instead, in the app/controllers directory, you'll re-open defined controllers, for the product.product controllers, it means creating a product_product_controller.rb file with:

$ class ProductProduct < OpenObjectsController
$   def foo
$     render :text => "bar"
$   end
$ end

Now, if you register that new method in your route.rb file GET /product_product/1/foo will render "bar" on your browser screen. You could instead just customize the existing CRUD methods so you don't need to regiter any other route in route.rb.