Skip to Content
Menu
This question has been flagged
7 Replies
15157 Views

I have a big pet peeve with Odoo documentation. I have previously worked with XML-RPC but is now switching to JSON-RPC. But I have always struggled to find good documentation. Only a few simple examples are to be found online - and often in some SDK of a certain language - not language-agnostic so that anyone can figure it out for their language. So I have a couple of core questions:


1. Why are there absolutely no instructions on how to find out which methods, fields and values are available in a JSON-RPC call? At the very minimum it could be stated that one can inspect the network requests in the browser to see examples...!


2. Why is there no explanation of the difference between the JSON-RPC API calls used in the browser and the JSON-RPC API meant for external use? This could help translating the browser requests into normal JSON-RPC requests.


This makes it very difficult (= very time consuming => waste of money) for people unfamiliar with Odoo to make integrations to it. A very undesirable effect.

Avatar
Discard
Best Answer

My 2 cents on the topic. 
Some tipps for beginners (which would have been very helpful for me:

If you want to create a simple interface for JSON RPC and are lucky enough to have python:


The plane request to create it in a different language (here in postman):
1) get Authentication (Then the Credentials get stored as cookies, standard web auth)

where newstart9 is your database name and admin admin are your username and password

2) Then you can, like in rest, create update(write in odoo), delete like in REST

http://localhost:8069/web/dataset/call_kw/forum.post/create
{

"id": 5,

"jsonrpc": "2.0",

"method": "call",

"params": {

"model": "forum.post",

"method": "create",

"args": [

{

"name": "PowerPoint Karaoke",

"subtitle": "Die besten Erfindungen der Neuzeit"

}

]

}


Why Json-RPC is cool:
The permission concept of odoo is honored, that means you don't have to worry about it, if the user has permissions he get's the data if he doesn't he won't get it.

And most importantly you are not limited to create, update, you basically can do everything your user has permission to do. So together with minor odoo developments it's very easy to achive complex workflows compared to the very limited cumbersome REST capabilites where you need a lot of development to do basic things.

But of course you can't get Swagger/OpenAPI interface files for JSON-RPC, correct em if I'm wrong.

You could use 
https://github.com/OCA/rest-framework than you get swagger/OpenAPI Interface but you still have to create everything yourself. 

There are also some commercial Products 
https://apps.odoo.com/apps/modules/18.0/muk_rest should be good, but never really used it myself.

As a Bonus: if you only need to get access to data have a look at web_search_read, it's a not well documented feature of odoo which they use heavily inhouse. It's basically graphql for odoo. So you tell him exactly what you need spanning multiple related models and he gives you just that. If you have to do some more complex requirements - you will save yourself a lot of tears and work compared to an REST based approach not speaking of speed as you need for the same request a lot REST requests ...

Avatar
Discard
Best Answer

NOTE: would have like to use the "commenting tool", but I don't have enough XP for that, so here is a non-answer :)

All the external ressources (tutorial, YouTube videos) are useful.

This is not enough, though: why the APIs does not have a clear auto-generated documentation? It makes it's usage overcomplicated. Also, the lack of examples makes things incredibly experimental. 

I had to rely on alternative documentation content from GitHub (created by the community, see link) to understand things. I think it could be reviewed by the Odoo team and merged to the existing doc. That would be very helpful for newcomers.

  • https://github.com/amlaksil/Odoo-JSON-RPC-API/

It's also confusing and not clear why the "External API" and "Web Services" docs are separated.

  • https://www.odoo.com/documentation/17.0/developer/reference/external_api.html#
  • https://www.odoo.com/documentation/master/developer/howtos/web_services.html


Avatar
Discard
Best Answer

(tried to use the "commenting tool", but that doesn't seem to work, so here is a non-answer:)

I can relate. We're migrating to Odoo DMS from Paperless, and this means I have to script the transfer of a couple tens of thousand documents, while preserving the metadata, such as tags, correspondents, notes, etc..

I've looked around but I cannot find a proper API description, nor any actual examples. It seems the external API is a simple wrapper around the models, but how do I get a list of models, and of the fields, and yes, it would really be useful to have an example of e.g. creating a DMS record with some tags and notes using the API.

Avatar
Discard
Best Answer

Hi,
See this tutorial about json rpc in odoo:  Odoo JSON RPC

Thanks

Avatar
Discard
Best Answer

Did you find any valuable documentation ? Looking for the same stuff without success

Avatar
Discard
Author Best Answer

You call that documentation?? It doesn't answer my questions at all! The articles are basically useless - extremely simple and a lot of info which is already obvious to a programmer!

Avatar
Discard
Author

Why can't I comment on Cybrosys' answer?!!

Author

I can't even delete my own answer and comments. What amateur system is this??

Related Posts Replies Views Activity
0
Feb 25
1136
1
May 24
3343
1
Nov 22
4668
0
Oct 20
4442
1
Apr 25
591