Monday, May 18, 2026
1 change · 17.0
New functionality added to Odoo
This update adds the ability to display JSON content with syntax highlighting within Odoo's Ace editor. Previously, custom modules using JSON data couldn't be formatted, but now users can view and interact with JSON data like configuration snapshots and API responses with proper code coloring and folding capabilities. This improves readability and usability for working with JSON data within Odoo.
Original PR description
## Summary - Vendors the canonical [ace-builds](https://github.com/ajaxorg/ace-builds) `mode-json.js` into the `web.ace_lib` bundle, so the Ace editor can syntax-highlight JSON content. - Registers…
## Summary
- Vendors the canonical [ace-builds](https://github.com/ajaxorg/ace-builds) `mode-json.js` into the `web.ace_lib` bundle, so the Ace editor can syntax-highlight JSON content.
- Registers `"json"` in `CodeEditor.MODES` so `widget="ace" options="{'mode': 'json'}"` passes the prop validator.
- For readonly editors only, re-enables `showGutter` and `showFoldWidgets` when `mode === "json"` — this is what makes the fold triangles in the gutter clickable for users viewing read-only JSON (config snapshots, API response logs, audit fields, etc.). Other modes keep their existing behavior of hiding the gutter when readonly.
## Why
Odoo ships the Ace editor with modes for `js`, `xml`, `qweb`, `python`, and `scss`, but not `json`. Custom modules that surface JSON payloads (third-party API responses, structured logs, configuration blobs) have no native way to render them with syntax highlighting; today they either fall back to a plain `<field>` or vendor their own `mode-json.js`, which is fragile.
This is the smallest change that solves the gap consistently for everyone:
- The mode lives next to the other vendored ace modes.
- The `CodeEditor` API surface is unchanged (just one more allowed value for `props.mode`).
- The readonly gutter override is narrowly scoped — no behavior change for any other mode.
The vendored `mode-json.js` is the standard ace-builds file, adapted minimally to match the existing files in `addons/web/static/lib/ace/`:
## Test plan
- [ ] In a development DB, open a view that renders an ace JSON field — e.g.
```xml
<field name="some_text_field" widget="ace" options="{'mode': 'json'}"/>
```
and confirm: syntax colors are applied; brace matching highlights pairs; `Ctrl+/` line-comments; typing JSON behaves the same as in `python` / `js` modes.
- [ ] On the same field with `readonly="1"`, confirm the gutter is visible and fold triangles appear next to every `{` and `[`. Clicking a triangle collapses the block; clicking it again expands. Keyboard shortcuts (`F2`, `Alt+L` / `Cmd+Option+L`) also fold/unfold.