From b56e6dfdcc8c2ee448f78d539f482734296fe866 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Wed, 30 Aug 2023 14:20:06 +0200 Subject: [PATCH] [IMP] web: show properties sum in list view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose ======= Always show the sum of a property column if its type is integer or float. When we group records we don't show the sum, because it will require to be able to aggregate properties (`properties.xxxxx:sum`) and the technical cost is too big for the feature it gives. Task-3468750 closes odoo/odoo#133700 Signed-off-by: Warnon Aurélien (awa) --- addons/web/static/src/views/list/list_renderer.js | 3 +++ addons/web/static/tests/views/list_view_tests.js | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index 0da9c2e0f28..5f40df65d41 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -280,6 +280,9 @@ export class ListRenderer extends Component { hasLabel: true, label: propertyField.string, sortable: false, + attrs: ["integer", "float"].includes(propertyField.type) + ? { sum: propertyField.string } + : {}, }; }); } diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 489eeaf5da1..818e0264643 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -18732,6 +18732,11 @@ QUnit.module("Views", (hooks) => { await clickSave(target); assert.strictEqual(target.querySelector(".o_field_cell.o_integer_cell").textContent, "321"); + assert.strictEqual( + target.querySelector(".o_list_footer .o_list_number").textContent, + "567", + "First property is 321, second is zero because it has a different parent and the 2 others are 123 so the total should be 321 + 123 * 2 = 567" + ); }); QUnit.test("Properties: float", async (assert) => { @@ -18780,6 +18785,11 @@ QUnit.module("Views", (hooks) => { await clickSave(target); assert.strictEqual(target.querySelector(".o_field_cell.o_float_cell").textContent, "3.21"); + assert.strictEqual( + target.querySelector(".o_list_footer .o_list_number").textContent, + "250.11", + "First property is 3.21, second is zero because it has a different parent and the 2 others are 123.45 so the total should be 3.21 + 123.45 * 2 = 250.11" + ); }); QUnit.test("Properties: date", async (assert) => {