OOOREST - OpenObject On Rails, REST layer
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.