From 58c64558a9a3188edccd1c60042de9f6e639b4a1 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 12 Apr 2019 08:20:01 +0000 Subject: [FIX] web: checkbox readonly is RO in list editable Since f4fbaf1efa the structure of checkboxes has been improved, now we have something like: ``` ``` With the first input invisible (whilst before it was visible and the clickable element). This cause an issue in an editable list view: - we have a boolean readonly field in a cell - we are on focused on a line (not in the boolean field cell) - we click on the boolean field => the check mark is toggled This is because when we switch cell, we try to activate the widget of the other cell. Before f4fbaf1efa this issue did not happen since the browser do not generate a click event when clicking a disabled checkbox. With this changeset, a disabled FieldBoolean is not focusable as is the case for other fields, so we can't "activate" it. Without the fix, the added test fails with: [clicking disabled checkbox did not work] opw-1958433 closes #32652 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/fields/basic_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index a4284841130..f924f24d2fa 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -805,7 +805,7 @@ var FieldBoolean = AbstractField.extend({ * @returns {jQuery} the focusable checkbox input */ getFocusableElement: function () { - return this.$input || $(); + return this.mode === 'readonly' ? $() : this.$input; }, /** * A boolean field is always set since false is a valid value. -- cgit v1.2.3 From c150ab367a787ae7e358952e2af76b75683a36c6 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 10 Apr 2019 12:33:45 +0000 Subject: [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) --- addons/web/static/src/js/fields/basic_fields.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 2c8968ca453..a4284841130 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -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 } }, -- cgit v1.2.3