diff --git a/addons/web/static/src/views/fields/jsonb/jsonb.js b/addons/web/static/src/views/fields/jsonb/jsonb.js new file mode 100644 index 00000000000..58dc2e1083f --- /dev/null +++ b/addons/web/static/src/views/fields/jsonb/jsonb.js @@ -0,0 +1,26 @@ +/** @odoo-module **/ + +import { _lt } from "@web/core/l10n/translation"; +import { registry } from "@web/core/registry"; +import { standardFieldProps } from "../standard_field_props"; + +import { Component } from "@odoo/owl"; + +export class JsonField extends Component { + static template = "web.JsonbField"; + static props = { + ...standardFieldProps, + }; + get formattedValue() { + const value = this.props.record.data[this.props.name]; + return value ? JSON.stringify(value) : ""; + } +} + +export const jsonField = { + component: JsonField, + displayName: _lt("Json"), + supportedTypes: ["jsonb"], +}; + +registry.category("fields").add("jsonb", jsonField); diff --git a/addons/web/static/src/views/fields/jsonb/jsonb.xml b/addons/web/static/src/views/fields/jsonb/jsonb.xml new file mode 100644 index 00000000000..ac059c152fb --- /dev/null +++ b/addons/web/static/src/views/fields/jsonb/jsonb.xml @@ -0,0 +1,8 @@ + + + + + + + +