mirror of https://github.com/OCA/web.git
[FIX] web_widget_numeric_step: Float Precision
parent
6c6566078a
commit
8357085d1d
|
@ -5,7 +5,7 @@
|
||||||
{
|
{
|
||||||
'name': "Web Widget Numeric Step",
|
'name': "Web Widget Numeric Step",
|
||||||
'category': "web",
|
'category': "web",
|
||||||
'version': "12.0.1.0.0",
|
'version': "12.0.1.1.0",
|
||||||
'author': "GRAP, Tecnativa, "
|
'author': "GRAP, Tecnativa, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
odoo.define('web_widget_numeric_step.field', function (require) {
|
odoo.define('web_widget_numeric_step.field', function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var field_utils = require('web.field_utils');
|
||||||
var Registry = require('web.field_registry');
|
var Registry = require('web.field_registry');
|
||||||
var FieldFloat = require('web.basic_fields').FieldFloat;
|
var FieldFloat = require('web.basic_fields').FieldFloat;
|
||||||
|
|
||||||
|
@ -204,18 +205,6 @@ odoo.define('web_widget_numeric_step.field', function (require) {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
/*
|
|
||||||
* Get field precision (really used by floats)
|
|
||||||
*/
|
|
||||||
_getPrecision: function () {
|
|
||||||
var field = this.record.fields[this.name];
|
|
||||||
if (field && 'digits' in field && field.digits.length === 2) {
|
|
||||||
return field.digits[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check limits and precision of the value.
|
* Check limits and precision of the value.
|
||||||
* If the value 'is not a number', the function does nothing to
|
* If the value 'is not a number', the function does nothing to
|
||||||
|
@ -234,7 +223,15 @@ odoo.define('web_widget_numeric_step.field', function (require) {
|
||||||
} else if (!_.isNaN(this._config.max) && cval > this._config.max) {
|
} else if (!_.isNaN(this._config.max) && cval > this._config.max) {
|
||||||
cval = this._config.max;
|
cval = this._config.max;
|
||||||
}
|
}
|
||||||
return cval.toFixed(this._getPrecision());
|
|
||||||
|
var field = this.record.fields[this.name];
|
||||||
|
var formattedValue = field_utils.format[field.type](cval, field, {
|
||||||
|
data: this.record.data,
|
||||||
|
escape: true,
|
||||||
|
isPassword: false,
|
||||||
|
digits: field.digits,
|
||||||
|
});
|
||||||
|
return formattedValue;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue