diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-07 12:21:05 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-07 12:21:05 +0200 |
| commit | 89819c6f420fb6ef2cdb963527c0a5fa2f6df02b (patch) | |
| tree | 4d3aa6721d90d8fee1db76cfcb00291913c37630 /addons/web/static/src | |
| parent | 333a58e4efefde29d7289c3b5ad55d525f815b8b (diff) | |
| parent | 1f74b878f4ceab5f8902a91a6f0aa4947ee2126b (diff) | |
[MERGE] forward port branch saas-14 up to 1f74b878f4c
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/form_widgets.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index 83a289d8d4f..5691bd68d44 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -1262,9 +1262,40 @@ var FieldBinaryFile = FieldBinary.extend({ }); } }, + /** + * Render the value of the binary file field + * + * The value depends on the mode (readonly/edit) and the attribute filename + * in the xml node of the field: + * + * + * with filename without filename + * [------------------|-----------------------] + * readonly: | saved filename | binary size | + * edit: | current filename | base64 representation | + * [------------------|-----------------------] + * + * + * This is how the filename is retrieved: + * + * - Suppose that the binary field is named 'data' + * - The xml node of this field is as follow: + * + * `<field name='data' filename='fdata'/>` + * + * - 'fdata' is another field whose value is the filename + * - On the following record: + * + * `{data: "Cg==1das02fa01", fdata: 'my-file.txt'}` + * + * - The content of the file is the value of 'data': Cg==1das02fa01 + * - The filename is the value of 'fdata': my-file.txt + */ render_value: function() { - var filename = this.view.datarecord[this.node.attrs.filename]; + var filename; if (this.get("effective_readonly")) { + // Filename from saved state (might render from a discard operation) + filename = this.view.datarecord[this.node.attrs.filename]; // do not forward-port >= 11.0 this.do_toggle(!!this.get('value')); if (this.get('value')) { this.$el.empty().append($("<span/>").addClass('fa fa-download')); @@ -1278,6 +1309,9 @@ var FieldBinaryFile = FieldBinary.extend({ } } } else { + // Filename at the moment (might be unsaved state) + var filenameField = this.field_manager.fields[this.node.attrs.filename]; // do not forward-port >= 11.0 + filename = filenameField ? filenameField.get('value') : ''; if(this.get('value')) { this.$el.children().removeClass('o_hidden'); this.$('.o_select_file_button').first().addClass('o_hidden'); |
