[FIX] spreadsheet: support properties field in lists
Steps to reproduce the issue: 1. Project> select Project > Task> List view 2. Studio list view > Add existing properties field 3. Go back to list view > Favorites > add to spreadsheet 4. New Spreadsheet > Will receive error opw-3284273 closes odoo/odoo#120473 X-original-commit: 5eb80e34db2e54b56164ea4b98bea3cebb09312b Signed-off-by: Rémi Rahir (rar) <rar@odoo.com> Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
This commit is contained in:
@@ -161,6 +161,10 @@ export default class ListDataSource extends OdooViewsDataSource {
|
||||
return record[fieldName] ? toNumber(this._formatDate(record[fieldName])) : "";
|
||||
case "datetime":
|
||||
return record[fieldName] ? toNumber(this._formatDateTime(record[fieldName])) : "";
|
||||
case "properties": {
|
||||
const properties = record[fieldName] || [];
|
||||
return properties.map((property) => property.string).join(", ");
|
||||
}
|
||||
default:
|
||||
return record[fieldName] || "";
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { createSpreadsheetWithList } from "../utils/list";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { RPCError } from "@web/core/network/rpc_service";
|
||||
import { getBasicServerData } from "../utils/data";
|
||||
|
||||
QUnit.module("spreadsheet > list plugin", {}, () => {
|
||||
QUnit.test("List export", async (assert) => {
|
||||
@@ -56,6 +57,24 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
|
||||
assert.strictEqual(getCellValue(model, "A5"), "FALSE");
|
||||
});
|
||||
|
||||
QUnit.test("properties field displays property display names", async (assert) => {
|
||||
const serverData = getBasicServerData();
|
||||
serverData.models.partner.records = [
|
||||
{
|
||||
id: 45,
|
||||
partner_properties: [
|
||||
{ name: "dbfc66e0afaa6a8d", type: "date", string: "prop 1", default: false },
|
||||
{ name: "f80b6fb58d0d4c72", type: "integer", string: "prop 2", default: 0 },
|
||||
],
|
||||
},
|
||||
];
|
||||
const { model } = await createSpreadsheetWithList({
|
||||
serverData,
|
||||
columns: ["partner_properties"],
|
||||
});
|
||||
assert.strictEqual(getCellValue(model, "A2"), "prop 1, prop 2");
|
||||
});
|
||||
|
||||
QUnit.test("Can display a field which is not in the columns", async function (assert) {
|
||||
const { model } = await createSpreadsheetWithList();
|
||||
setCellContent(model, "A1", `=ODOO.LIST(1,1,"active")`);
|
||||
|
||||
@@ -341,6 +341,13 @@ export function getBasicData() {
|
||||
group_operator: "avg",
|
||||
searchable: true,
|
||||
},
|
||||
partner_properties: {
|
||||
string: "Properties",
|
||||
type: "properties",
|
||||
store: true,
|
||||
sortable: true,
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
records: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user