diff --git a/addons/web/static/src/views/fields/binary/binary_field.js b/addons/web/static/src/views/fields/binary/binary_field.js index 27b30b87af8..ad170b6d972 100644 --- a/addons/web/static/src/views/fields/binary/binary_field.js +++ b/addons/web/static/src/views/fields/binary/binary_field.js @@ -47,19 +47,23 @@ export class BinaryField extends Component { return this.props.record.update(changes); } + getDownloadData() { + return { + model: this.props.record.resModel, + id: this.props.record.resId, + field: this.props.name, + filename_field: this.fileName, + filename: this.fileName || "", + download: true, + data: isBinarySize(this.props.record.data[this.props.name]) + ? null + : this.props.record.data[this.props.name], + }; + } + async onFileDownload() { await download({ - data: { - model: this.props.record.resModel, - id: this.props.record.resId, - field: this.props.name, - filename_field: this.fileName, - filename: this.fileName || "", - download: true, - data: isBinarySize(this.props.record.data[this.props.name]) - ? null - : this.props.record.data[this.props.name], - }, + data: this.getDownloadData(), url: "/web/content", }); } diff --git a/addons/web/static/src/views/fields/binary/binary_field.xml b/addons/web/static/src/views/fields/binary/binary_field.xml index c2f6fdb34d2..ad202ef93c9 100644 --- a/addons/web/static/src/views/fields/binary/binary_field.xml +++ b/addons/web/static/src/views/fields/binary/binary_field.xml @@ -9,7 +9,7 @@ acceptedFileExtensions="props.acceptedFileExtensions" onUploaded.bind="update" > - +