Skip to content

[19.0][FIX] endpoint: serialize payload values with Odoo's json_default - #160

Open
yostashiro wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-fix-endpoint-json_default
Open

[19.0][FIX] endpoint: serialize payload values with Odoo's json_default#160
yostashiro wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-fix-endpoint-json_default

Conversation

@yostashiro

Copy link
Copy Markdown
Member

_make_json_response called json.dumps() with no default= hook, so any payload value json cannot represent natively raised TypeError and the request returned a 500. Every other JSON response in Odoo goes through json.dumps(data, default=json_default) (odoo/http.py).

Pass the same hook here. It covers date, datetime, bytes, Domain, lazy and ReadonlyDict, and json.dumps applies it at every depth, so nested values are handled without walking the payload.

Also let an endpoint supply its own hook through the result dict, for exec modes that need to override how a type is rendered. json.dumps takes a single default= callable, so such a hook replaces Odoo's for the whole payload and is expected to delegate to json_default for the types it does not render itself.

Assisted-by: Claude Opus 5

@qrtl QT6815

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @simahawk,
some modules you are maintaining are being modified, check this out!

_make_json_response called json.dumps() with no default= hook, so any
payload value json cannot represent natively raised TypeError and the
request returned a 500. Every other JSON response in Odoo goes through
json.dumps(data, default=json_default) (odoo/http.py).

Pass the same hook here. It covers date, datetime, bytes, Domain, lazy
and ReadonlyDict, and json.dumps applies it at every depth, so nested
values are handled without walking the payload.

Also let an endpoint supply its own hook through the result dict, for
exec modes that need to override how a type is rendered. json.dumps
takes a single default= callable, so such a hook replaces Odoo's for the
whole payload and is expected to delegate to json_default for the types
it does not render itself.

Assisted-by: Claude Opus 5
@yostashiro
yostashiro force-pushed the 19.0-fix-endpoint-json_default branch from bf660ed to b1428cb Compare August 30, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants