[FIX] spreadsheet: raise error for json fields in lists
The json fields are not supported in lists at the moment because they require additional RPC to fetch the display value as long as its formatting. closes odoo/odoo#122074 Task: 3324679 X-original-commit: 9e6d598e6a96434c68634149ecf1acf3e714ca03 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com> Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
@@ -2138,6 +2138,13 @@ msgstr ""
|
||||
msgid "Field name."
|
||||
msgstr ""
|
||||
|
||||
#. module: spreadsheet
|
||||
#. odoo-javascript
|
||||
#: code:addons/spreadsheet/static/src/list/list_data_source.js:0
|
||||
#, python-format
|
||||
msgid "Fields of type \"%s\" are not supported"
|
||||
msgstr ""
|
||||
|
||||
#. module: spreadsheet
|
||||
#. odoo-javascript
|
||||
#: code:addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js:0
|
||||
|
||||
@@ -165,6 +165,8 @@ export default class ListDataSource extends OdooViewsDataSource {
|
||||
const properties = record[fieldName] || [];
|
||||
return properties.map((property) => property.string).join(", ");
|
||||
}
|
||||
case "json":
|
||||
throw new Error(sprintf(_t('Fields of type "%s" are not supported'), "json"));
|
||||
default:
|
||||
return record[fieldName] || "";
|
||||
}
|
||||
|
||||
@@ -119,6 +119,22 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
|
||||
assert.strictEqual(getEvaluatedCell(model, "G3").format, "[$$]#,##0.00");
|
||||
});
|
||||
|
||||
QUnit.test("Json fields are not supported in list formulas", async function (assert) {
|
||||
const { model } = await createSpreadsheetWithList({
|
||||
columns: ["foo", "jsonField"],
|
||||
linesNumber: 2,
|
||||
});
|
||||
setCellContent(model, "A1", `=ODOO.LIST(1,1,"foo")`);
|
||||
setCellContent(model, "A2", `=ODOO.LIST(1,1,"jsonField")`);
|
||||
await waitForDataSourcesLoaded(model);
|
||||
assert.strictEqual(getEvaluatedCell(model, "A1").value, 12);
|
||||
assert.strictEqual(getEvaluatedCell(model, "A2").value, "#ERROR");
|
||||
assert.strictEqual(
|
||||
getEvaluatedCell(model, "A2").error.message,
|
||||
`Fields of type "json" are not supported`
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("can select a List from cell formula", async function (assert) {
|
||||
const { model } = await createSpreadsheetWithList();
|
||||
const sheetId = model.getters.getActiveSheetId();
|
||||
|
||||
@@ -348,6 +348,11 @@ export function getBasicData() {
|
||||
sortable: true,
|
||||
searchable: true,
|
||||
},
|
||||
jsonField: {
|
||||
string: "Json Field",
|
||||
type: "json",
|
||||
store: true,
|
||||
},
|
||||
},
|
||||
records: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user