Search code examples
web-servicescontrollerodoo-8odooxml-rpc

When should I use XML-RPC instead of a Controller in Odoo?


I'm very confusing with this both concepts of exchanging information. I asked a question few days ago and it seems I was doing wrong.

Are the controllers web services or kind of? Only XML-RPC is a web service?

So I would like to know when I should use a controller on Odoo and when I should use XML-RPC to exchange information between Odoo and any other different application.

Which is the safest way?

In my previous question I wanted the client to send me information about some customers to create them in the database. Somebody posted a comment recommending me to do it with XML-RPC. So in which cases should I use a controller? Is it only used if I want to sent back a website to the client as a response?

I didn't find any clue in the Odoo documentation. However I found some XML-RPC examples in some languages (Python, Ruby, PHP, Java) in the Odoo documentation. Maybe to do the things with a controller is more convenient if the client, who sends me the information, does not work with those languages. Is it?

I would appreciate any help.


Solution

  • If you are simply using CRUD (Create,Read,Update,Delete) you almost definitely want to use the xmlrpc/jsonrpc interfaces. You can even you xmlrpc/jsonrpc to execute custom commands on you models as well. So xmlrpc is a structured means of executing authenticated exchanges between your client and the server.

    If you want to provide complex json data back to your client or make unauthenticated interactions from client->server then a controller is definitely the way to go.

    Controllers are also very useful for the Odoo Webpage services. Making redirecting to the proper page or loading the appropriate template and handling form data very easy.

    Whatever works for your design needs may be correct for you, however Odoo has created services for handling normal CRUD interactions and executing model functions and it is advisable to benefit from Odoo's work and use your hard programming time to create your own structures where needed.

    Here is Odoo's docs.

    xmlrpc