From 23e705286188ed76a20e82a37bc0311d78feefdd Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Thu, 29 Sep 2022 12:00:11 +0000 Subject: [PATCH] [FIX] web: delete a record in a grouped kanban Before this commit, in a grouped kanban view, when the "delete" button of a card is clicked, the card is deleted but a "Load more..." is displayed in the column. Why is this? The group counter is not correctly decremented when the record is deleted How to reproduce : - Go to a grouped kanban view with a delete button on its cards - Click on the delete button Before this commit: The record is deleted and "Load more..." is displayed in the record column. After this commit: The record is deleted. closes odoo/odoo#101817 X-original-commit: c97551a5aac6eaa0ca3d750039a65e3e03a453da Signed-off-by: Aaron Bohy (aab) --- .../web/static/src/views/relational_model.js | 5 ++-- .../static/tests/views/kanban_view_tests.js | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/relational_model.js b/addons/web/static/src/views/relational_model.js index c56d0064391..6488f76d751 100644 --- a/addons/web/static/src/views/relational_model.js +++ b/addons/web/static/src/views/relational_model.js @@ -2579,8 +2579,9 @@ export class Group extends DataPoint { /** * @see DynamicRecordList.deleteRecords */ - async deleteRecords() { - return this.list.deleteRecords(...arguments); + async deleteRecords(records) { + this.count = this.count - records.length; + return this.list.deleteRecords(records); } empty() { diff --git a/addons/web/static/tests/views/kanban_view_tests.js b/addons/web/static/tests/views/kanban_view_tests.js index dec16634d35..a7f77960c13 100644 --- a/addons/web/static/tests/views/kanban_view_tests.js +++ b/addons/web/static/tests/views/kanban_view_tests.js @@ -1182,6 +1182,36 @@ QUnit.module("Views", (hooks) => { } ); + QUnit.test("click on a button type='delete' to delete a record in a column", async (assert) => { + await makeView({ + type: "kanban", + resModel: "partner", + serverData, + arch: ` + + +
+ + +
+
+
+
`, + groupBy: ["product_id"], + }); + let column = getColumn(); + assert.containsN(column, ".o_kanban_record", 2); + assert.containsNone(column, ".o_kanban_load_more"); + + await click(column.querySelector(".o_kanban_record .o_delete")); + assert.containsOnce(target, ".modal"); + + await click(target, ".modal .btn-primary"); + column = getColumn(); + assert.containsOnce(column, ".o_kanban_record"); + assert.containsNone(column, ".o_kanban_load_more"); + }); + QUnit.test("kanban with an action id as on_create attrs", async (assert) => { const actionService = { start() {