From 94c91374e33f80256398f7ac2f892500aaf7e685 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 18 May 2017 09:36:14 +0200 Subject: [FIX] web: selection field with value 0 The server doesn't make a distinction between an unset selection field, and a value 0 (integer). So when 0 is a valid key for the field, the server returns false as value if the field is unset, or if its value is 0, which is not really convenient. As a consequence, when the value is 0, it appears as unset in the interface. To circumvent this, we automatically converts false value of selection fields to 0, if 0 is a key of the selection. --- addons/web/static/src/js/fields/field_utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/fields/field_utils.js') diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 98fafcef7f1..aabf5e2ae95 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -296,12 +296,12 @@ function formatMonetary(value, field, options) { * @param {boolean} [options.escape=false] if true, escapes the formatted value */ function formatSelection(value, field, options) { - if (!value) { - return ''; - } var val = _.find(field.selection, function (option) { return option[0] === value; }); + if (!val) { + return ''; + } value = val[1]; if (options && options.escape) { value = _.escape(value); -- cgit v1.2.3