[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 <dam@odoo.com>
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Co-authored-by: Nicolas Lempereur <nle@odoo.com>
This commit is contained in:
Jordan D. (Joda)
2023-06-07 21:34:48 +02:00
committed by Mathieu Duckerts-Antoine
co-authored by Nicolas Lempereur
parent c2db5515a2
commit 6c8ad13c65
2 changed files with 30 additions and 1 deletions
+4 -1
View File
@@ -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;
}
}
@@ -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: `
<pivot>
<field name="price_nonaggregatable"/>
</pivot>`,
});
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);