[FIX] web: some float fields silently ignores their changes

We have an interesting problem when editing all custom float fields and all
fields with no explicit digit attributes: the propertiesmixin tries to
check if the number was changed, according to their declared precision.
But for these specific fields, it does not find a digit attribute, and
defaults to 2.  Then, it makes sure that the changes are ignored if the
new value is too close to the old value (with 2 digits precision)

For example, if the user sets the value to 1.234, then save, then change
it to 1.235, then save, the form view will display 1.234 and totally
ignore the change.

Not that handling the digit precision is done in the propertiesmixin and
in the field float widget.  Also, they do different things, and in some
case, may not be the same.   All this logic should be moved to the
fieldfloat widget.
This commit is contained in:
Géry Debongnie
2016-04-04 12:18:17 +02:00
parent e49893ab2d
commit 3d4954b88f
+2 -4
View File
@@ -325,9 +325,8 @@ var PropertiesMixin = _.extend({}, EventDispatcherMixin, {
// remove this, or move it elsewhere. Also, learn OO programming.
if (key === 'value' && self.field && self.field.type === 'float' && tmp && val){
var digits = self.field.digits;
if (digits !== 0){
digits = digits ? digits[1] : 2;
if (utils.float_is_zero(tmp - val, digits)) {
if (_.isArray(digits)) {
if (utils.float_is_zero(tmp - val, digits[1])) {
return;
}
}
@@ -355,4 +354,3 @@ return {
};
});