From ece5f26c105c3e98d18ed5df584620387eca952d Mon Sep 17 00:00:00 2001 From: Adrien Schoffeniels Date: Wed, 26 Apr 2023 07:28:44 +0000 Subject: [PATCH] [FIX] web: use copy of fields when using a kanban model Since commit [1], properties can be displayed in list views. However, when switching from a kanban view showing the properties to a list view that should be showing the same properties, these are not shown. This happens because the model in the kanban controller currently uses a reference of the fields. When loading the list view, the properties are thus already in the fields, and they are skipped when trying to apply them. This commit solves the issue by working with a copy of the fields in the kanban controller, as the list controller does since commit [1]. [1]: https://github.com/odoo/odoo/commit/70619d0e6a23f955265c99aa6b25924357e46223 Task-3284508 closes odoo/odoo#120128 X-original-commit: 4ccb018ef1d301d2e52fea05b4949d77049be3ca Signed-off-by: David Beguin (dbe) Signed-off-by: Thibault Delavallee (tde) --- .../src/views/kanban/kanban_controller.js | 2 +- .../views/fields/properties_field_tests.js | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/kanban/kanban_controller.js b/addons/web/static/src/views/kanban/kanban_controller.js index 63a4f76a4a6..26387658bc9 100644 --- a/addons/web/static/src/views/kanban/kanban_controller.js +++ b/addons/web/static/src/views/kanban/kanban_controller.js @@ -84,7 +84,7 @@ export class KanbanController extends Component { return { activeFields: archInfo.activeFields, progressAttributes: archInfo.progressAttributes, - fields, + fields: { ...fields }, resModel, handleField: archInfo.handleField, limit: archInfo.limit || limit, 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 0ad4f8b87d2..7397b992230 100644 --- a/addons/web/static/tests/views/fields/properties_field_tests.js +++ b/addons/web/static/tests/views/fields/properties_field_tests.js @@ -11,6 +11,7 @@ import { patchWithCleanup, triggerEvent, } from "@web/../tests/helpers/utils"; +import { createWebClient, doAction } from "@web/../tests/webclient/helpers"; import { Many2XAutocomplete } from "@web/views/fields/relational_utils"; import { makeView, setupViewRegistries } from "@web/../tests/views/helpers"; import { SelectCreateDialog } from "@web/views/view_dialogs/select_create_dialog"; @@ -1356,6 +1357,44 @@ QUnit.module("Fields", (hooks) => { assert.equal(items.length, 2); }); + /** + * Check that the properties are shown when switching view. + */ + QUnit.test("properties: switch view", async function (assert) { + serverData.views = { + "partner,false,search": ``, + "partner,99,kanban": ` + + +
+
+
+ +
+
+
+
`, + "partner,100,list": ` + + + `, + }; + const wc = await createWebClient({ serverData }); + await doAction(wc, { + res_model: "partner", + type: "ir.actions.act_window", + views: [ + [false, "kanban"], + [false, "list"], + ], + }); + + await click(target, ".o_switch_view.o_list"); + assert.ok(target.querySelector(".o_optional_columns_dropdown"), + "Properties should be added as optional columns." + ); + }); + /** * Test the behavior of the default value. It should be propagated on the property * value only when we create a new property. If the property already exists, and we