[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.
pull/2456/head
Alexandre Díaz 2020-03-11 17:31:44 +01:00 committed by dsolanki
parent 322bb8cebf
commit dae7e4e21b
2 changed files with 9 additions and 7 deletions

View File

@ -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',

View File

@ -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