From 2a5488619da22cfd901963dd141e722b195e82ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Ku=CC=88hn?= Date: Sun, 14 Jan 2018 21:34:13 +0100 Subject: [FIX] web: disable {bin_size: true} on binary fields Revision on 41fe7f9d1113d026b226b136b4477aaaf9f1f638 This commit intended to reduce the network load when reading records with binary fields. This was made possible by enforcing the contextual key `bin_size` to be set for records with binary fields. However, it is causing some issues (see #22222, #22231) which are: - write with bin_size:true generates a traceback - read/search_read with bin_size:true breaks some images on some views (e.g. base.view_partner_form) Since the problems outweight the gain of these changes, we revert them. --- addons/web/static/src/js/fields/basic_fields.js | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index aab0e42c318..09406b43711 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1080,7 +1080,6 @@ var AbstractFieldBinary = AbstractField.extend({ }, 'click .o_clear_file_button': 'on_clear', }), - context: { bin_size: true }, init: function (parent, name, record) { this._super.apply(this, arguments); this.fields = record.fields; -- cgit v1.2.3 From 290e247e823731ddd2a064a579677adcad1eccdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Ku=CC=88hn?= Date: Wed, 17 Jan 2018 10:27:09 +0100 Subject: [FIX] web: remove dead code Cleaning dead code from these commits that have been reverted: 41fe7f9d1113d026b226b136b4477aaaf9f1f638#diff-54fd886cc58f994ad518ee72df4d3edeR50 2a5488619da22cfd901963dd141e722b195e82ab#diff-f96b339a9374f74489f1f98755e9787bL9253 41fe7f9d1113d026b226b136b4477aaaf9f1f638#diff-86d6d41b5bb7499bf055258d05549d59R3111 With these final changes, we hope to stop the many issues that have occured with binary fields, from these commits: 255e8ca3d92e3a77d7c2a145677623518bc2f978 7813a8e714f268983b0be88827ae1c8ad887e6c7 41fe7f9d1113d026b226b136b4477aaaf9f1f638 2a5488619da22cfd901963dd141e722b195e82ab What remains is the format of binary fields in list views without widgets, which shows the bin_size instead of the base64 string representation... ... Rest assured, the computation is in JS, so there are no 'bin_size' shenaningans! --- addons/web/static/src/js/fields/abstract_field.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index 8bb9afca065..2534f8ae90a 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -44,11 +44,6 @@ var AbstractField = Widget.extend({ navigation_move: '_onNavigationMove', }, - /** - * fields can extend the context, e.g. binary fields add {bin_size: true} - */ - context: null, - /** * An object representing fields to be fetched by the model eventhough not present in the view * This object contains "field name" as key and an object as value. -- cgit v1.2.3 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/fields') 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