diff options
| author | Alexandre Kühn <alex.e.kuhn@gmail.com> | 2018-01-09 12:04:21 +0100 |
|---|---|---|
| committer | Alexandre Kühn <alexkuhn@users.noreply.github.com> | 2018-01-12 16:12:49 +0100 |
| commit | 41fe7f9d1113d026b226b136b4477aaaf9f1f638 (patch) | |
| tree | bcaf1204fdcc6a54fc497c23b1ec227d414cddfd /addons/web/static/src/js/fields | |
| parent | 7813a8e714f268983b0be88827ae1c8ad887e6c7 (diff) | |
[FIX] web: contexts on field widgets + enforce bin_size for binary
Field widgets now have a key 'context' that let them
extend the context of the dataPoint (e.g. list).
In particular, widgets on binary fields enforce the contextual
item {bin_size: True}, so that the server gives the size of the
binary field as its value, instead of its content.
This change on binary fields reduces network load when accessing
a view with binary fields.
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/abstract_field.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index 2534f8ae90a..8bb9afca065 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -45,6 +45,11 @@ var AbstractField = Widget.extend({ }, /** + * 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. * That value object must contain the key "type" diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 09406b43711..aab0e42c318 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1080,6 +1080,7 @@ 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; |
