[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) <aab@odoo.com>
This commit is contained in:
FrancoisGe
2022-10-01 14:52:22 +02:00
parent 40df434b2d
commit 23e7052861
2 changed files with 33 additions and 2 deletions
@@ -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() {
@@ -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: `<kanban limit="3">
<templates>
<t t-name="kanban-box">
<div>
<div><a role="menuitem" type="delete" class="dropdown-item o_delete">Delete</a></div>
<field name="foo"/>
</div>
</t>
</templates>
</kanban>`,
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() {