diff --git a/addons/web/static/src/model/relational_model/static_list.js b/addons/web/static/src/model/relational_model/static_list.js index 4ba40616026..ba108e89d9e 100644 --- a/addons/web/static/src/model/relational_model/static_list.js +++ b/addons/web/static/src/model/relational_model/static_list.js @@ -716,7 +716,7 @@ export class StaticList extends DataPoint { const id = resId || params.virtualId; const config = { context: this.context, - activeFields: params.activeFields || this.activeFields, + activeFields: Object.assign({}, params.activeFields || this.activeFields), resModel: this.resModel, fields: params.fields || this.fields, relationField: this.config.relationField, diff --git a/addons/web/static/tests/views/fields/one2many_field_tests.js b/addons/web/static/tests/views/fields/one2many_field_tests.js index e43fc90d492..d500f6311d2 100644 --- a/addons/web/static/tests/views/fields/one2many_field_tests.js +++ b/addons/web/static/tests/views/fields/one2many_field_tests.js @@ -14445,4 +14445,68 @@ QUnit.module("Fields", (hooks) => { ); } ); + + QUnit.test( + "x2many kanban with float field in form (non inline) but not in kanban", + async function (assert) { + // In this test, the form view contains an extra float field and isn't inline. When we open + // a record, we add the form fields to the list of activeFields, and we load the + // corresponding data (for that record only). Afterwards, we force a re-rendering of the + // x2many kanban to ensure that the other record can still be rendered. Before the fix coming + // with this test, it wasn't the case, because those records had extra activeFields, but no + // entry in data for those fields. + serverData.models.partner.records[0].turtles = [2, 3]; + serverData.views = { + "turtle,false,form": ` +
`, + }; + + await makeView({ + type: "form", + resModel: "partner", + serverData, + arch: ` + `, + resId: 1, + }); + + assert.containsOnce(target, ".o_field_widget[name=turtles]"); + assert.containsN(target, ".o_kanban_record:not(.o_kanban_ghost)", 2); + + // open the first record + await click(target.querySelector(".o_kanban_record")); + assert.containsOnce(target, ".o_dialog"); + assert.containsOnce(target, ".o_dialog .o_field_widget[name=turtle_qux]"); + + // close the dialog + await click(target.querySelector(".o_dialog .o_form_button_save")); + assert.containsNone(target, ".o_dialog"); + + // toggle bar to make the x2many invisible + await click(target, ".o_field_widget[name=bar] input"); + assert.containsNone(target, ".o_field_widget[name=turtles]"); + + // toggle bar again to make the x2many visible and force kanban cards to re-render + await click(target, ".o_field_widget[name=bar] input"); + assert.containsOnce(target, ".o_field_widget[name=turtles]"); + assert.containsN(target, ".o_kanban_record:not(.o_kanban_ghost)", 2); + } + ); });