From 1983ec11d0fb108f3dafac3ef4ffbcc8c6058b2e Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 7 Nov 2023 10:36:29 +0000 Subject: [PATCH] [FIX] web: kanban: disallow to quick create if cannot create Before this commit, a grouped kanban view with create="0" on the root node would still allow to quick create record in columns (i.e. the "+" icon would still be displayed). However, clicking on it would most likely raise an AccessError as the user isn't allowed to create records. This commit restores the pre 16.0 behavior, which is to disallow quick creation if the user can't create. Task 3559638 closes odoo/odoo#141631 X-original-commit: 775475aaed6ea88f54a6530b81f35f3114431716 Signed-off-by: Aaron Bohy (aab) Signed-off-by: Jorge Pinna Puissant (jpp) --- .../static/src/views/kanban/kanban_arch_parser.js | 15 +++++++-------- .../tests/views/kanban/kanban_view_tests.js | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/views/kanban/kanban_arch_parser.js b/addons/web/static/src/views/kanban/kanban_arch_parser.js index e01d75a20f1..9825b256120 100644 --- a/addons/web/static/src/views/kanban/kanban_arch_parser.js +++ b/addons/web/static/src/views/kanban/kanban_arch_parser.js @@ -34,14 +34,13 @@ export class KanbanArchParser { const countLimit = xmlDoc.getAttribute("count_limit"); const recordsDraggable = archParseBoolean(xmlDoc.getAttribute("records_draggable"), true); const groupsDraggable = archParseBoolean(xmlDoc.getAttribute("groups_draggable"), true); - const activeActions = { - ...getActiveActions(xmlDoc), - archiveGroup: archParseBoolean(xmlDoc.getAttribute("archivable"), true), - createGroup: archParseBoolean(xmlDoc.getAttribute("group_create"), true), - deleteGroup: archParseBoolean(xmlDoc.getAttribute("group_delete"), true), - editGroup: archParseBoolean(xmlDoc.getAttribute("group_edit"), true), - quickCreate: archParseBoolean(xmlDoc.getAttribute("quick_create"), true), - }; + const activeActions = getActiveActions(xmlDoc); + activeActions.archiveGroup = archParseBoolean(xmlDoc.getAttribute("archivable"), true); + activeActions.createGroup = archParseBoolean(xmlDoc.getAttribute("group_create"), true); + activeActions.deleteGroup = archParseBoolean(xmlDoc.getAttribute("group_delete"), true); + activeActions.editGroup = archParseBoolean(xmlDoc.getAttribute("group_edit"), true); + activeActions.quickCreate = + activeActions.create && archParseBoolean(xmlDoc.getAttribute("quick_create"), true); const onCreate = xmlDoc.getAttribute("on_create"); const quickCreateView = xmlDoc.getAttribute("quick_create_view"); const tooltipInfo = {}; diff --git a/addons/web/static/tests/views/kanban/kanban_view_tests.js b/addons/web/static/tests/views/kanban/kanban_view_tests.js index 3dcb56a9022..ab5aeaaf520 100644 --- a/addons/web/static/tests/views/kanban/kanban_view_tests.js +++ b/addons/web/static/tests/views/kanban/kanban_view_tests.js @@ -5621,6 +5621,8 @@ QUnit.module("Views", (hooks) => { }); assert.containsNone(target, ".o-kanban-button-new"); + assert.containsN(target, ".o_kanban_group", 2); + assert.containsNone(target, ".o_kanban_quick_add"); }); QUnit.test("clicking on a link triggers correct event", async (assert) => {