Skip to content

[IMP] Add support for JSON-2 API (Odoo >= 19.0 with API key)#109

Merged
sebalix merged 3 commits into
OCA:masterfrom
sebalix:new-jsonrpc-api
May 15, 2026
Merged

[IMP] Add support for JSON-2 API (Odoo >= 19.0 with API key)#109
sebalix merged 3 commits into
OCA:masterfrom
sebalix:new-jsonrpc-api

Conversation

@sebalix
Copy link
Copy Markdown
Collaborator

@sebalix sebalix commented Apr 17, 2026

Address #101

What's changed with JSON-2 API enabled

  • ODOO.login() now accepts a new keyword argument api_key, used only if Odoo >= 19.0. If set, login and password parameters will be ignored, and new ODOO.json2_ready property will return True, meaning the connection is using JSON-2 API.
  • Positional arguments are automatically transformed into named parameters thanks to the new /doc-bearer/<model>.json endpoint which provides method signatures.
  • new ODOO.json2_ready property can be used by users to detect if current connection is JSON-2 ready (and adapt RPC queries accordingly)

TODO :

  • adapt odoorpc.db to use /web/database controllers

@sebalix sebalix added this to the v0.11.0 milestone Apr 17, 2026
@sebalix sebalix force-pushed the new-jsonrpc-api branch 3 times, most recently from 0f18c52 to 91a1b29 Compare April 20, 2026 09:53
@Julien00859
Copy link
Copy Markdown

Julien00859 commented May 4, 2026

odoo.env["res.partner"].create({"name": "Joe"}) # /!\ DOESN'T WORK ANYMORE WITH JSON-2
odoo.env["res.partner"].create(vals_list={"name": "Joe"}) # Keyword arguments must be used

I could be a good idea to special-case the few CRUD (create, search, write, unlink) methods and to have an automatic rewrite positional -> keyword handled by the lib.

@sebalix
Copy link
Copy Markdown
Collaborator Author

sebalix commented May 5, 2026

@Julien00859 I was wondering the same indeed. At first it was a design to not implement methods client-side but browse, but it could be convenient at this point.

@Julien00859
Copy link
Copy Markdown

One last thing, you can download the technical documentation of every model through the /doc/<model_name>.json (session cookie) or /doc-bearer/<model_name>.json (http authentication header, with an API key), that technical documentation contains the exact signature of every method. When we updated1 our own odoo-client-lib, we decided to download those documents to translate on-the-fly positional arguments to named one. I'm not saying you should do the same, I'm merely sharing our own experience migrating jsonrpc -> json2 🙂

Footnotes

  1. https://github.com/odoo/odoo-client-lib/commit/2b5956025048f7e70f47b6ab72529ae1d1965509

@sebalix
Copy link
Copy Markdown
Collaborator Author

sebalix commented May 5, 2026

@Julien00859 nice! Good to know indeed

@sebalix sebalix force-pushed the new-jsonrpc-api branch 2 times, most recently from 159e56b to 6806ec1 Compare May 15, 2026 10:21
sebalix added 3 commits May 15, 2026 12:21
…>= 19.0

This change introduces a new dependency against the `requests` package to
ease the upload of multipart form-data content.
@sebalix sebalix force-pushed the new-jsonrpc-api branch from 6806ec1 to dfe2089 Compare May 15, 2026 10:28
@sebalix
Copy link
Copy Markdown
Collaborator Author

sebalix commented May 15, 2026

@Julien00859 thank you for your input about /doc-bearer/<model>.json endpoint, there is no breaking change anymore in OdooRPC with this! (so no need to adapt the documentation and confuse users).

@sebalix sebalix marked this pull request as ready for review May 15, 2026 10:31
@sebalix sebalix merged commit 4c7a11b into OCA:master May 15, 2026
13 checks passed
@sebalix sebalix deleted the new-jsonrpc-api branch May 15, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants