diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 2c3e03681db..350dc5f5674 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1634,6 +1634,7 @@ var AbstractFieldBinary = AbstractField.extend({ this.fields = record.fields; this.useFileAPI = !!window.FileReader; this.max_upload_size = 64 * 1024 * 1024; // 64Mo + this.accepted_file_extensions = (this.nodeOptions && this.nodeOptions.accepted_file_extensions) || this.accepted_file_extensions || '*'; if (!this.useFileAPI) { var self = this; this.fileupload_id = _.uniqueId('o_fileupload'); @@ -1765,6 +1766,7 @@ var FieldBinaryImage = AbstractFieldBinary.extend({ 'i': 'png', 'P': 'svg+xml', }, + accepted_file_extensions: 'image/*', /** * Returns the image URL from a model. * @@ -1976,6 +1978,7 @@ var FieldPdfViewer = FieldBinaryFile.extend({ description: _lt("PDF Viewer"), supportedFieldTypes: ['binary'], template: 'FieldPdfViewer', + accepted_file_extensions: 'application/pdf', /** * @override */ diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 2b6a0d44854..4a68c140056 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -2007,6 +2007,7 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({ this.uploadedFiles = {}; this.uploadingFiles = []; this.fileupload_id = _.uniqueId('oe_fileupload_temp'); + this.accepted_file_extensions = (this.nodeOptions && this.nodeOptions.accepted_file_extensions) || this.accepted_file_extensions || '*'; $(window).on(this.fileupload_id, this._onFileLoaded.bind(this)); this.metadata = {}; diff --git a/addons/web/static/src/js/views/kanban/kanban_record.js b/addons/web/static/src/js/views/kanban/kanban_record.js index 0c4213c60b7..ab19e73d2eb 100644 --- a/addons/web/static/src/js/views/kanban/kanban_record.js +++ b/addons/web/static/src/js/views/kanban/kanban_record.js @@ -395,7 +395,7 @@ var KanbanRecord = Widget.extend({ fields: ['id', 'name'], }).then(function (attachmentIds) { self.imageUploadID = _.uniqueId('o_cover_image_upload'); - self.image_only = true; // prevent uploading of other file types + self.accepted_file_extensions = 'image/*'; // prevent uploading of other file types var coverId = self.record[fieldName] && self.record[fieldName].raw_value; var $content = $(QWeb.render('KanbanView.SetCoverModal', { coverId: coverId, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index b76e86c036d..7800bc1a218 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -872,7 +872,6 @@ Uploading... - @@ -924,8 +923,8 @@ method="post" enctype="multipart/form-data" t-att-action="fileupload_action || '/web/binary/upload'"> - - +