3
0
Fork 0

[FIX] web_widget_numeric_step: Change number parse method

Previous this commit the widget only works with 'dots', with
this commit works using odoo parse method that support other separators.
12.0
Alexandre Díaz 2020-03-11 17:31:44 +01:00
parent de873eeb3d
commit f751b9e71a
1 changed files with 8 additions and 6 deletions

View File

@ -31,7 +31,6 @@ odoo.define('web_widget_numeric_step.field', function (require) {
DELAY_THROTTLE_CHANGE: 200, DELAY_THROTTLE_CHANGE: 200,
_prevValue: null, // Used to know if the value was really changed
init: function () { init: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
@ -133,9 +132,13 @@ odoo.define('web_widget_numeric_step.field', function (require) {
* @param {String} mode can be "plus" or "minus" * @param {String} mode can be "plus" or "minus"
*/ */
_doStep: function (mode) { _doStep: function (mode) {
var cval = Number(this.$input.val()); var cval = 0;
if (_.isNaN(cval)) { try {
return; var field = this.record.fields[this.name];
cval = field_utils.parse[field.type](this.$input.val())
} catch {
cval = this.value;
mode = false; // Only set the value in this case
} }
if (mode === 'plus') { if (mode === 'plus') {
cval += this._config.step; cval += this._config.step;
@ -143,13 +146,12 @@ odoo.define('web_widget_numeric_step.field', function (require) {
cval -= this._config.step; cval -= this._config.step;
} }
var nval = this._sanitizeNumberValue(cval); var nval = this._sanitizeNumberValue(cval);
if (nval !== this._prevValue) { if (nval !== this.lastSetValue || !mode) {
this.$input.val(nval); this.$input.val(nval);
// Every time that user update the value we must trigger an // Every time that user update the value we must trigger an
// onchange method. // onchange method.
this._lazyOnChangeTrigger(); this._lazyOnChangeTrigger();
} }
this._prevValue = nval;
}, },
// Handle Events // Handle Events