This question has been flagged
3 Replies
20162 Views

My company is using Purchase, Sale and Accounting module in OpenERP. We have few business apllications.User can store informations from Accout module in OpenERP as well as from different businesses. For storing information from different businesses we need RESTful API. Can any one help providing some guide lines and examples. Your suggestion will be highly appreciate. Thank you.

Avatar
Discard

OpenERP Official : Support for REST-style webservices is planned for future releases of OpenERP.

They had mention in doc

Author

Zahin, They mentioned in openerp v6. I am using v7. let me confirm, whether v7 has REST-style or not.

Best Answer

First go to addons/web/http.py and study class JsonRequest. Then go to addons/web/controllers/main.py for examples on using whats in http.py. Everything you need to develop your own API spec is in there - authentication, session handlers, JSON object spec, methods for searching/updating object through the ORM etc. etc.

main.py illustrates how to define your own controllers and endpoints and provides many useful reusable methods to help avoid reinventing the wheel.

Avatar
Discard
Author

Thank you so much Mike for your valuable time. Let me clear one thing, what you told is it for RESTful API ? I think it's JSON RPC, correct me if i'm wrong. I went through JsonRequest in addons/web/http.py and also addons/web/controllers/main.py. I'm not clear after studing those classes. Can you please provide me one simple example on accounting module, implementing all CRUD operation in RESTful API.

Sorry I should have pointed you to HttpRequest in http.py instead. A good example of its usage is upload_attachment in main.py where POST data in the request is used to create an OpenERP object. I'm sorry but I don't have time to give a more complete example right now. Basically you'll define endpoints using _cp_path in your controller class and then add methods for each CRUD operation. Honestly, it would probably be easier to use Django-Tastypie for your API and leverage the OpenERP/Django connector to access OpenERP models.

Author

Thanks a lot Mike. Sorry for taking your time, does OpenERP v7 support MySQL ? If so, give some guide lines for migrating DB to MySQL.

Best Answer

Or you could use an ESB to translate the different apps messaging formats to the one you prefer. For this I suggest having a look at Zato.

Avatar
Discard

Thank you for the Zato link.

Best Answer

Use this : https://github.com/tgpfeiffer/restful-openerp

Avatar
Discard