diff --git a/addons/web/static/src/model/relational_model/relational_model.js b/addons/web/static/src/model/relational_model/relational_model.js
index 9acc0fecaa2..e0483b54766 100644
--- a/addons/web/static/src/model/relational_model/relational_model.js
+++ b/addons/web/static/src/model/relational_model/relational_model.js
@@ -195,7 +195,7 @@ export class RelationalModel extends Model {
for (const record of records) {
for (const fieldName in record) {
const field = config.fields[fieldName];
- if (fieldName !== "id" && field.type === "properties") {
+ if (fieldName !== "id" && field.type === "properties" && record[fieldName]) {
const parent = record[field.definition_record];
const relatedPropertyField = {
fieldName,
diff --git a/addons/web/static/tests/views/fields/properties_field_tests.js b/addons/web/static/tests/views/fields/properties_field_tests.js
index fa576935445..6bd37b8f57d 100644
--- a/addons/web/static/tests/views/fields/properties_field_tests.js
+++ b/addons/web/static/tests/views/fields/properties_field_tests.js
@@ -1353,34 +1353,36 @@ QUnit.module("Fields", (hooks) => {
assert.equal(items.length, 2);
});
- QUnit.test("properties: kanban view with date and datetime property fields", async function (assert) {
- serverData.models.partner.records.push({
- id: 40,
- display_name: "fifth partner",
- properties: [
- {
- name: "property_1",
- string: "My Date",
- type: "date",
- value: "2019-01-01",
- view_in_kanban: true,
- },
- {
- name: "property_2",
- string: "My DateTime",
- type: "datetime",
- value: "2019-01-01 10:00:00",
- view_in_kanban: true,
- },
- ],
- company_id: 37,
- });
+ QUnit.test(
+ "properties: kanban view with date and datetime property fields",
+ async function (assert) {
+ serverData.models.partner.records.push({
+ id: 40,
+ display_name: "fifth partner",
+ properties: [
+ {
+ name: "property_1",
+ string: "My Date",
+ type: "date",
+ value: "2019-01-01",
+ view_in_kanban: true,
+ },
+ {
+ name: "property_2",
+ string: "My DateTime",
+ type: "datetime",
+ value: "2019-01-01 10:00:00",
+ view_in_kanban: true,
+ },
+ ],
+ company_id: 37,
+ });
- await makeView({
- type: "kanban",
- resModel: "partner",
- serverData,
- arch: `
+ await makeView({
+ type: "kanban",
+ resModel: "partner",
+ serverData,
+ arch: `
@@ -1392,18 +1394,19 @@ QUnit.module("Fields", (hooks) => {
`,
- });
+ });
- // check fifth card
- const property1 = target.querySelector(
- ".o_kanban_record:nth-child(5) .o_kanban_property_field:nth-child(1) span"
- );
- assert.equal(property1.innerText, "01/01/2019");
- const property2 = target.querySelector(
- ".o_kanban_record:nth-child(5) .o_kanban_property_field:nth-child(2) span"
- );
- assert.equal(property2.innerText, "01/01/2019 11:00:00");
- });
+ // check fifth card
+ const property1 = target.querySelector(
+ ".o_kanban_record:nth-child(5) .o_kanban_property_field:nth-child(1) span"
+ );
+ assert.equal(property1.innerText, "01/01/2019");
+ const property2 = target.querySelector(
+ ".o_kanban_record:nth-child(5) .o_kanban_property_field:nth-child(2) span"
+ );
+ assert.equal(property2.innerText, "01/01/2019 11:00:00");
+ }
+ );
QUnit.test(
"properties: kanban view with multiple sources of properties definitions",
@@ -1570,6 +1573,38 @@ QUnit.module("Fields", (hooks) => {
);
});
+ QUnit.test("properties: kanban view without properties", async function (assert) {
+ serverData.models.partner.records = [
+ {
+ id: 40,
+ display_name: "first partner",
+ properties: false,
+ company_id: 37,
+ },
+ ];
+ await makeView({
+ type: "kanban",
+ resModel: "partner",
+ serverData,
+ arch: `
+
+
+
+
+
+
+
+
+
+
+ `,
+ });
+ assert.strictEqual(
+ target.querySelector(".o_kanban_record").textContent,
+ "Company 1 first partner "
+ );
+ });
+
/**
* Check that the properties are shown when switching view.
*/