diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-05-18 09:36:14 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-18 13:55:46 +0200 |
| commit | 94c91374e33f80256398f7ac2f892500aaf7e685 (patch) | |
| tree | ad086e6c0b5bb751021ede9be38b8f3b1f0c03af /addons/web/static/src/js/fields/field_utils.js | |
| parent | 3dd97db07fcf22bf1dd7fcaa912a20438483bc7c (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src/js/fields/field_utils.js')
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 6 |
1 files changed, 3 insertions, 3 deletions
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); |
