From 6c8ad13c65181be801dc9391c4e8975cc9575f2a Mon Sep 17 00:00:00 2001 From: "Jordan D. (Joda)" Date: Tue, 9 May 2023 15:11:05 +0000 Subject: [PATCH] [FIX] web: error when checking amount in currency How to reproduce ================ * Install the account_accountant module * Go to `Journal Items` * Select the pivot view * Select the measure `Amount in Currency` => A traceback will occur Cause ===== Field amount_currency has group_operator set to none to avoid grouping several amount in different current together. Proposed fix ============ If the `group_operator==None`, The field will not be shown as aggregator. opw-3061776 closes odoo/odoo#124179 X-original-commit: beccce4d5ec26e885c06c5af4cb1d6147cb0e91f Related: odoo/enterprise#42127 Signed-off-by: Mathieu Duckerts-Antoine Signed-off-by: Nicolas Lempereur (nle) Co-authored-by: Nicolas Lempereur --- addons/web/static/src/views/utils.js | 5 +++- .../static/tests/views/pivot_view_tests.js | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/utils.js b/addons/web/static/src/views/utils.js index 2a9c8a5acdf..2ca88ca41f9 100644 --- a/addons/web/static/src/views/utils.js +++ b/addons/web/static/src/views/utils.js @@ -136,7 +136,10 @@ export const computeReportMeasures = (fields, fieldAttrs, activeMeasures) => { if (isInvisible) { continue; } - if (["integer", "float", "monetary"].includes(field.type)) { + if ( + ["integer", "float", "monetary"].includes(field.type) && + field.group_operator !== undefined + ) { measures[fieldName] = field; } } diff --git a/addons/web/static/tests/views/pivot_view_tests.js b/addons/web/static/tests/views/pivot_view_tests.js index 6858076f65b..6349d2b9d3f 100644 --- a/addons/web/static/tests/views/pivot_view_tests.js +++ b/addons/web/static/tests/views/pivot_view_tests.js @@ -110,6 +110,12 @@ QUnit.module("Views", (hooks) => { sortable: true, store: true, }, + price_nonaggregatable: { + string: "Price non-aggregatable", + type: "monetary", + group_operator: undefined, + store: true, + }, }, records: [ { @@ -441,6 +447,26 @@ QUnit.module("Views", (hooks) => { } ); + QUnit.test( + "pivot view do not add number field without group_operator", + async function (assert) { + await makeView({ + type: "pivot", + resModel: "partner", + serverData, + arch: ` + + + `, + }); + await click(target.querySelector(".o_pivot_buttons button.dropdown-toggle")); + assert.containsNone( + target, + ".o_cp_bottom_left .dropdown-menu .dropdown-item:contains(Price non-aggregatable)" + ); + } + ); + QUnit.test("clicking on a cell triggers a doAction", async function (assert) { assert.expect(2);