From b8c8eaa02fbb7312d026e1fc519f80384d1cebe9 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 18 Jan 2018 14:23:09 +0100 Subject: [FIX] web: error image when no kanban image Introduce back part of `formatBinary` that was reverted with 7813a8e7. When an image is unset, the value was `false` which would end up with a bin_size of `NaN Bytes` which would end up displaying an error image with source `data:image/png;base64,NaN Bytes`. This commit get back a previous behavior so the bin_size when the attachment does not exist is an empty string (so: ''). opw-805542 closes #22348 --- addons/web/static/src/js/fields/field_utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 5ac180b1de1..5a11f1b0ba8 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -30,7 +30,7 @@ var _t = core._t; /** * Convert binary to bin_size * - * @param {string} value base64 representation of the binary (might be already a bin_size!) + * @param {string} [value] base64 representation of the binary (might be already a bin_size!) * @param {Object} [field] * a description of the field (note: this parameter is ignored) * @param {Object} [options] additional options (note: this parameter is ignored) @@ -38,6 +38,9 @@ var _t = core._t; * @returns {string} bin_size (which is human-readable) */ function formatBinary(value, field, options) { + if (!value) { + return ''; + } return utils.binaryToBinsize(value); } -- cgit v1.2.3