From df6c716bc23be5e2dd5b1a8c8393e28e48e0ec1c Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Mon, 10 Oct 2022 12:01:16 +0000 Subject: [PATCH] [FIX] web: kanban: attribute default_order Before this commit the attribute default_order was not taken into consideration by the kanban view. closes odoo/odoo#103127 X-original-commit: 0116b590a47c8c12354877498e576ad28e42c1f2 Signed-off-by: Bruno Boi (boi) --- .../src/views/kanban/kanban_controller.js | 1 + .../static/tests/views/kanban_view_tests.js | 59 +++++++++++++++---- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/addons/web/static/src/views/kanban/kanban_controller.js b/addons/web/static/src/views/kanban/kanban_controller.js index a8b031710e9..08609dceb3d 100644 --- a/addons/web/static/src/views/kanban/kanban_controller.js +++ b/addons/web/static/src/views/kanban/kanban_controller.js @@ -28,6 +28,7 @@ export class KanbanController extends Component { onCreate: archInfo.onCreate, quickCreateView: archInfo.quickCreateView, defaultGroupBy, + defaultOrder: archInfo.defaultOrder, viewMode: "kanban", openGroupsByDefault: true, tooltipInfo: archInfo.tooltipInfo, diff --git a/addons/web/static/tests/views/kanban_view_tests.js b/addons/web/static/tests/views/kanban_view_tests.js index 5ce462ca885..f94e2d3eeaa 100644 --- a/addons/web/static/tests/views/kanban_view_tests.js +++ b/addons/web/static/tests/views/kanban_view_tests.js @@ -9710,18 +9710,18 @@ QUnit.module("Views", (hooks) => { if (route === "/web/dataset/resequence") { assert.deepEqual( args.ids, - [2, 3, 4, 1], + [2, 1, 3, 4], "should write the sequence in correct order" ); } }, }); - assert.deepEqual(getCardTexts(), ["yop", "blip", "gnap", "blip"]); + assert.deepEqual(getCardTexts(), ["blip", "blip", "yop", "gnap"]); await dragAndDrop(".o_kanban_record", ".o_kanban_record:nth-child(4)"); - assert.deepEqual(getCardTexts(), ["blip", "gnap", "blip", "yop"]); + assert.deepEqual(getCardTexts(), ["blip", "yop", "gnap", "blip"]); }); QUnit.test("ungrouped kanban without handle field", async (assert) => { @@ -11414,26 +11414,25 @@ QUnit.module("Views", (hooks) => { [...target.querySelectorAll(".o_kanban_record:not(.o_kanban_ghost)")].map( (el) => el.innerText ), - ["yop", "blip", "gnap", "blip"] + ["blip", "blip", "yop", "gnap"] ); assert.verifySteps([]); - // move "yop" to second place - await dragAndDrop(".o_kanban_record", ".o_kanban_record:nth-child(2)"); + // move second "blip" to third place + await dragAndDrop(".o_kanban_record:nth-child(2)", ".o_kanban_record:nth-child(3)"); assert.deepEqual( [...target.querySelectorAll(".o_kanban_record:not(.o_kanban_ghost)")].map( (el) => el.innerText ), - ["yop", "blip", "gnap", "blip"] + ["blip", "blip", "yop", "gnap"] ); assert.verifySteps(["resequence"]); // try again - await dragAndDrop(".o_kanban_record", ".o_kanban_record:nth-child(2)"); - - assert.verifySteps([]); + await dragAndDrop(".o_kanban_record:nth-child(2)", ".o_kanban_record:nth-child(3)"); + -assert.verifySteps([]); def.resolve(); await nextTick(); @@ -11442,16 +11441,16 @@ QUnit.module("Views", (hooks) => { [...target.querySelectorAll(".o_kanban_record:not(.o_kanban_ghost)")].map( (el) => el.innerText ), - ["blip", "yop", "gnap", "blip"] + ["blip", "yop", "blip", "gnap"] ); - await dragAndDrop(".o_kanban_record:nth-child(2)", ".o_kanban_record:nth-child(3)"); + await dragAndDrop(".o_kanban_record:nth-child(3)", ".o_kanban_record:nth-child(4)"); assert.deepEqual( [...target.querySelectorAll(".o_kanban_record:not(.o_kanban_ghost)")].map( (el) => el.innerText ), - ["blip", "gnap", "yop", "blip"] + ["blip", "yop", "gnap", "blip"] ); assert.verifySteps(["resequence"]); }); @@ -12162,4 +12161,38 @@ QUnit.module("Views", (hooks) => { assert.containsNone(target, ".o_kanban_record.o_dragged"); }); + + QUnit.test("attribute default_order", async function (assert) { + serverData.models.custom_model = { + fields: { + int: { type: "integer", string: "Int" }, + }, + records: [ + { id: 1, int: 1 }, + { id: 2, int: 3 }, + { id: 3, int: 2 }, + ], + }; + + await makeView({ + type: "kanban", + resModel: "custom_model", + serverData, + arch: ` + + +
+ +
+
+
+ `, + }); + assert.deepEqual( + [...target.querySelectorAll(".o_kanban_record:not(.o_kanban_ghost)")].map( + (el) => el.innerText + ), + ["1", "2", "3"] + ); + }); });