From fc67391f5bf8cb74e07916df05c5f940670ef748 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Tue, 21 Feb 2023 15:26:44 +0000 Subject: [PATCH] [IMP] web: use formatFloatFactor for float_toggle widget Before this commit, the formatter used for `float_toggle` widget is `formatFloat` function, but the `value` parameter should be computed with the factor set on the widget. This calculation is also done in `formatFloatFactor` function before calling the formatFloat function. This commit uses the `formatFloatFactor` to uniform the code instead of doing the calculation in 2 different sides (one in the widget and one in the `formatFloatFactor`). task-2702636 Part-of: odoo/odoo#108605 --- .../src/views/fields/float_toggle/float_toggle_field.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/fields/float_toggle/float_toggle_field.js b/addons/web/static/src/views/fields/float_toggle/float_toggle_field.js index 8c34bc24adf..3f8df723db1 100644 --- a/addons/web/static/src/views/fields/float_toggle/float_toggle_field.js +++ b/addons/web/static/src/views/fields/float_toggle/float_toggle_field.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; -import { formatFloat } from "../formatters"; +import { formatFloatFactor } from "../formatters"; import { standardFieldProps } from "../standard_field_props"; import { Component } from "@odoo/owl"; @@ -46,8 +46,9 @@ export class FloatToggleField extends Component { return !this.props.digits && Array.isArray(fieldDigits) ? fieldDigits : this.props.digits; } get formattedValue() { - return formatFloat(this.props.record.data[this.props.name] * this.factor, { + return formatFloatFactor(this.props.record.data[this.props.name], { digits: this.digits, + factor: this.factor, }); } }