[FIX] web: FieldFloatToggle cell multi language

Have a timesheet uom per Day
Have a language with a different number format than English

Click on grid cell to change its value

Before this commit, the value was stuck on the highest value in range
This was because the parsing of the value into float was not taking into account
the real format of the float

After this commit, it works in all languages

OPW 1964657

closes odoo/odoo#32581

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Lucas Perais (lpe)
2019-04-10 12:33:45 +00:00
parent c9d3653f48
commit c150ab367a
@@ -1035,7 +1035,13 @@ var FieldFloatToggle = AbstractField.extend({
* @returns {float} The current formatted value
*/
_getDisplayedValue: function () {
return parseFloat(this._formatValue(this.value));
// this.value is a plain float
// Matches what is in Database
var usrFormatValue = this._formatValue(this.value);
// usrFormatValue is string
// contains a float represented in a user specific format
// the float is the fraction by [this.factor] of this.value
return field_utils.parse['float'](usrFormatValue);
},
/**
* Formats the HTML input tag for edit mode and stores selection status.
@@ -1062,7 +1068,7 @@ var FieldFloatToggle = AbstractField.extend({
* one is not in the range, the next value of the closest one will be chosen.
*
* @private
* @returns {number} The next formatted value in the range
* @returns {number} The next value in the range
*/
_nextValue: function () {
var range = this.nodeOptions.range;
@@ -1091,7 +1097,8 @@ var FieldFloatToggle = AbstractField.extend({
if (this.mode === 'edit') {
ev.stopPropagation(); // only stop propagation in edit mode
var next_val = this._nextValue();
this._setValue(next_val.toString()); // will be parsed in _setValue
next_val = field_utils.format['float'](next_val);
this._setValue(next_val); // will be parsed in _setValue
}
},