Switch the connector to JSON-RPC; drive records with buttons
JSON-RPC is the recommended Odoo API from 19 on. odoo_connect.py now posts to /jsonrpc over stdlib urllib instead of xmlrpc.client — same x()/get_or_create()/ fields_named() surface, common.version() becomes version(), server errors raise OdooError with Odoo's message, 600s timeout so module installs survive. Also: state changes must go through the model's own button method, never a write on state. Writing the field skips the delivery order, the journal entries, the sequence and the validations a hero feature exists to demonstrate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d913cdf09a
commit
3fd2c51a3d
@@ -1,6 +1,6 @@
|
||||
# Odoo 19 (Enterprise) — field names & footguns
|
||||
|
||||
Hard-won notes from a real v19 demo build over XML-RPC. Check these before you waste a build cycle. Always confirm the major version first: `common.version()["server_version"]`.
|
||||
Hard-won notes from a real v19 demo build over JSON-RPC. Check these before you waste a build cycle. Always confirm the major version first: `version()["server_version"]`.
|
||||
|
||||
## Renamed core fields (these break v17/v18 code)
|
||||
| Concept | v17/18 | **v19** |
|
||||
@@ -11,7 +11,7 @@ Hard-won notes from a real v19 demo build over XML-RPC. Check these before you w
|
||||
|
||||
A custom module that sets `category_id` on `res.groups` or `groups_id` on `res.users` will fail to install on v19 with `Invalid field ... / Cannot ...`. Drop the category or use `privilege_id`.
|
||||
|
||||
## fields_get returns null attributes over XML-RPC (some v19 builds)
|
||||
## fields_get returns null attributes over RPC (some v19 builds)
|
||||
`fields_get([], {"attributes": ["string","type"]})` may return each field with `string=None`. The **keys (technical names) are still correct** — match on keys, not labels. (`fields_named()` in `odoo_connect.py` does this.)
|
||||
|
||||
## Product model (v19)
|
||||
@@ -37,9 +37,14 @@ A custom module that sets `category_id` on `res.groups` or `groups_id` on `res.u
|
||||
## Stock seeding (so deliveries go Ready)
|
||||
- Create `stock.quant` with `inventory_quantity` and `context={"inventory_mode": True}`, then call `action_apply_inventory` with the same context. The apply may warn harmlessly if already applied; check by reserving (`stock.picking.action_assign` → state `assigned`).
|
||||
|
||||
## XML-RPC helper footgun
|
||||
## State fields are read-only in practice
|
||||
- `state` on `sale.order` / `account.move` / `stock.picking` is writable over RPC and doing so is always wrong: it skips the workflow. Confirming an SO with `write` creates no delivery and no invoice basis; posting a move with `write` creates no journal entries and no sequence number.
|
||||
- Use the button method: `action_confirm`, `action_post` / `button_draft` / `button_cancel`, `action_assign` + `button_validate`, `button_confirm` (PO).
|
||||
- `stock.picking.button_validate` can return a wizard dict (`stock.backorder.confirmation`, immediate transfer) instead of `True` — create the wizard from `res_model`/`context` and call its `process` button.
|
||||
|
||||
## RPC helper footgun
|
||||
- `execute_kw(..., method, args, kwargs)`: a **context dict must go in kwargs**, never as a positional arg. `search(domain, {"active_test":False})` sends the dict as `offset` → `psycopg2 can't adapt type 'dict'`. Pass `context=` as a keyword (see `x()` in `odoo_connect.py`).
|
||||
|
||||
## Module install over XML-RPC
|
||||
- `x("ir.module.module","button_immediate_install",[ids])`. Heavy — let it run minutes. On a failed XML-data load it rolls back cleanly (module stays uninstalled); fix and retry.
|
||||
## Module install over RPC
|
||||
- `x("ir.module.module","button_immediate_install",[ids])`. Heavy — let it run minutes (the JSON-RPC connector uses a 600s timeout for this reason). On a failed XML-data load it rolls back cleanly (module stays uninstalled); fix and retry.
|
||||
- After deploying a custom module to git (Odoo.sh), wait for the rebuild, then `x("ir.module.module","update_list")` and search for it before installing.
|
||||
|
||||
Reference in New Issue
Block a user