From dae7e4e21bc0386e20ec3fc577789f5da8a8a05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Wed, 11 Mar 2020 17:31:44 +0100 Subject: [PATCH] [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. --- web_widget_numeric_step/__manifest__.py | 2 +- .../static/src/js/numeric_step.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web_widget_numeric_step/__manifest__.py b/web_widget_numeric_step/__manifest__.py index efc3a37e4..06c7375ea 100644 --- a/web_widget_numeric_step/__manifest__.py +++ b/web_widget_numeric_step/__manifest__.py @@ -5,7 +5,7 @@ { 'name': "Web Widget Numeric Step", 'category': "web", - 'version': "12.0.1.1.1", + 'version': "12.0.1.1.2", 'author': "GRAP, Tecnativa, " "Odoo Community Association (OCA)", 'license': 'AGPL-3', diff --git a/web_widget_numeric_step/static/src/js/numeric_step.js b/web_widget_numeric_step/static/src/js/numeric_step.js index 46310fa68..bac11eabe 100644 --- a/web_widget_numeric_step/static/src/js/numeric_step.js +++ b/web_widget_numeric_step/static/src/js/numeric_step.js @@ -31,7 +31,6 @@ odoo.define('web_widget_numeric_step.field', function (require) { DELAY_THROTTLE_CHANGE: 200, - _prevValue: null, // Used to know if the value was really changed init: function () { 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" */ _doStep: function (mode) { - var cval = Number(this.$input.val()); - if (_.isNaN(cval)) { - return; + var cval = 0; + try { + 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') { cval += this._config.step; @@ -143,13 +146,12 @@ odoo.define('web_widget_numeric_step.field', function (require) { cval -= this._config.step; } var nval = this._sanitizeNumberValue(cval); - if (nval !== this._prevValue) { + if (nval !== this.lastSetValue || !mode) { this.$input.val(nval); // Every time that user update the value we must trigger an // onchange method. this._lazyOnChangeTrigger(); } - this._prevValue = nval; }, // Handle Events