mirror of https://github.com/OCA/web.git
[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
parent
322bb8cebf
commit
dae7e4e21b
|
@ -5,7 +5,7 @@
|
||||||
{
|
{
|
||||||
'name': "Web Widget Numeric Step",
|
'name': "Web Widget Numeric Step",
|
||||||
'category': "web",
|
'category': "web",
|
||||||
'version': "12.0.1.1.1",
|
'version': "12.0.1.1.2",
|
||||||
'author': "GRAP, Tecnativa, "
|
'author': "GRAP, Tecnativa, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue