From 3d4954b88f2a4e75dee6d0b74c79b924ae0d6d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 4 Apr 2016 11:51:58 +0200 Subject: [PATCH] [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. --- addons/web/static/src/js/framework/mixins.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/framework/mixins.js b/addons/web/static/src/js/framework/mixins.js index c80f486b92b..c79ae127fa5 100644 --- a/addons/web/static/src/js/framework/mixins.js +++ b/addons/web/static/src/js/framework/mixins.js @@ -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 { }; }); -