From 9792d5d76191dc3823ea62e9047787daf7afd0bc Mon Sep 17 00:00:00 2001 From: std-odoo Date: Tue, 23 Jan 2024 15:24:36 +0100 Subject: [PATCH] [FIX] web: decimal property crash in list view Bug === The decimal property crash when added in a list view, if some records have False as a value. Technical ========= Since fe797a03285ec9c81d29ed631839c91e2b9957a4 , we use the wrong Formatter in the Float field. Task-3698415 closes odoo/odoo#150682 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/views/fields/float/float_field.js | 2 +- addons/web/static/tests/views/list_view_tests.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/views/fields/float/float_field.js b/addons/web/static/src/views/fields/float/float_field.js index b3699a172da..0ef2e002cb6 100644 --- a/addons/web/static/src/views/fields/float/float_field.js +++ b/addons/web/static/src/views/fields/float/float_field.js @@ -4,7 +4,7 @@ import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { useInputField } from "../input_field_hook"; import { useNumpadDecimal } from "../numpad_decimal_hook"; -import { formatFloat } from "@web/core/utils/numbers"; +import { formatFloat } from "../formatters"; import { parseFloat } from "../parsers"; import { standardFieldProps } from "../standard_field_props"; diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index c81bc71154f..fad81de01ce 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -18820,7 +18820,7 @@ QUnit.module("Views", (hooks) => { serverData.models.bar.records[0].definitions = [definition]; for (const record of serverData.models.foo.records) { if (record.m2o === 1) { - record.properties = [{ ...definition, value: 123.45 }]; + record.properties = [{ ...definition, value: record.id === 4 ? false : 123.45 }]; } } @@ -18859,8 +18859,8 @@ QUnit.module("Views", (hooks) => { 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" + "126.66", + "First property is 3.21, second is zero because it has a different parent the other is 123.45 and the last one zero because it is false so the total should be 3.21 + 123.45 = 126.66" ); });