Skip to content

Odoo adapter: fix create, write, method kwargs and the connection test - #822

Merged
keysersoft merged 2 commits into
mainfrom
keysersoft/odoo-json2-write-fix
Oct 2, 2026
Merged

keysersoft merged 2 commits into
mainfrom
keysersoft/odoo-json2-write-fix

Conversation

@keysersoft

Copy link
Copy Markdown
Contributor

Tested the catalog Odoo adapter against a live Odoo 19 Enterprise instance through the real RestEngine. Reads (partners, sale orders, invoices, products, search_read, read, fields_get, search_count) worked. Every write failed with 422, and two Cloud workspaces that installed the connector today hit exactly these errors.

Tool Before Cause Now
odoo_create 422 body {values}; Odoo's create takes vals_list {"vals_list": [values]}, returns [id]
odoo_write 422 body {values}; write takes vals {"ids", "vals"}
odoo_call_method with kwargs 422/500 arguments nested under kwargs; JSON-2 binds each top-level key to a parameter new __merge in bodyMapping spreads them to the top level
odoo_search_count without domain 422 domain is a required argument domain required in the schema
Test connection 404 sends GET; /json/2 is POST only GET /doc-bearer/res.country.state.json (bearer-checked, 401 on a wrong key)

__merge (rest.engine.ts mapParams): an object argument whose keys become top-level body keys. Explicit keys win; __proto__/constructor/prototype are rejected like in bodyTemplate.

Live run after the fix: create → write → read → activity_schedule with summary and deadline → the activity is there → unlink, all OK; the test record was removed.

Tested against a live Odoo 19 (JSON-2 API). Reads worked; everything that
writes failed with 422, and real users hit it:

- odoo_create sent {values}; Odoo's create takes vals_list.
- odoo_write sent {values}; Odoo's write takes vals.
- odoo_call_method nested the arguments under "kwargs", but JSON-2 binds
  every top-level body key to a method parameter. A new `__merge` key in
  bodyMapping spreads an object argument into the top level of the body
  (explicit keys win, prototype keys rejected).
- odoo_search_count needs a domain; it is now required ([] counts all).
- The connection test sends GET, and /json/2 only answers POST (404). It
  now reads the bearer-authenticated API doc of a small model, which also
  rejects a wrong key with 401.
@keysersoft
keysersoft requested a review from D3nisty as a code owner October 2, 2026 15:40
Comment thread packages/backend/src/connectors/engines/rest.engine.ts Fixed
@keysersoft
keysersoft merged commit 48d2938 into main Oct 2, 2026
13 checks passed
@keysersoft
keysersoft deleted the keysersoft/odoo-json2-write-fix branch October 2, 2026 16:16
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants