From 40c9986d7d29761d2fbfeeabcf0409384f45485d Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 5 Sep 2022 14:38:55 +0000 Subject: [PATCH] [FIX] web: kanban: reload after creating a record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In kanban arch, one can set the attribute "on_create" on the root node to an action xmlid. In this case, when the user clicks on "Create", the action is executed. When this action is in target new, it opens a dialog (typically to create a record...). Before this commit, we didn't reload the kanban after closing the dialog. As a consequence, the newly created record wasn't displayed. For instance, it was the case in the Recruitement dashboard. closes odoo/odoo#99589 Signed-off-by: Géry Debongnie --- .../src/views/kanban/kanban_controller.js | 9 +++- .../static/tests/views/kanban_view_tests.js | 44 +++++++++++++++++++ 2 files changed, 52 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 981ff92f1d4..b6be1edfca3 100644 --- a/addons/web/static/src/views/kanban/kanban_controller.js +++ b/addons/web/static/src/views/kanban/kanban_controller.js @@ -89,7 +89,14 @@ export class KanbanController extends Component { if (onCreate === "quick_create" && root.canQuickCreate()) { await root.quickCreate(group); } else if (onCreate && onCreate !== "quick_create") { - await this.actionService.doAction(onCreate, { additionalContext: root.context }); + const options = { + additionalContext: root.context, + onClose: async () => { + await this.model.root.load(); + this.render(true); // FIXME WOWL reactivity + }, + }; + await this.actionService.doAction(onCreate, options); } else { await this.props.createRecord(); } diff --git a/addons/web/static/tests/views/kanban_view_tests.js b/addons/web/static/tests/views/kanban_view_tests.js index 2eb66a9286c..580c9b5d89c 100644 --- a/addons/web/static/tests/views/kanban_view_tests.js +++ b/addons/web/static/tests/views/kanban_view_tests.js @@ -1150,6 +1150,50 @@ QUnit.module("Views", (hooks) => { } ); + QUnit.test("kanban with an action id as on_create attrs", async (assert) => { + const actionService = { + start() { + return { + doAction: (action, options) => { + // simplified flow in this test: simulate a target new action which + // creates a record and closes itself + assert.step(`doAction ${action}`); + serverData.models.partner.records.push({ id: 299, foo: "new" }); + options.onClose(); + }, + }; + }, + }; + registry.category("services").add("action", actionService, { force: true }); + + await makeView({ + type: "kanban", + resModel: "partner", + serverData, + arch: ` + + + +
+
+
+
`, + mockRPC(route, args) { + assert.step(args.method); + }, + }); + + assert.containsN(target, ".o_kanban_record:not(.o_kanban_ghost)", 4); + await createRecord(); + assert.containsN(target, ".o_kanban_record:not(.o_kanban_ghost)", 5); + assert.verifySteps([ + "get_views", + "web_search_read", + "doAction some.action", + "web_search_read", + ]); + }); + QUnit.test("create in grouped on m2o", async (assert) => { await makeView({ type: "kanban",