diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index e864f6341f9..92f2e163b99 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -2095,6 +2095,22 @@ QUnit.module('basic_fields', {
session.get_file = oldGetFile;
});
+ QUnit.test('binary fields: option accepted_file_extensions', async function (assert) {
+ assert.expect(1);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: ``
+ });
+ assert.strictEqual(form.$('input.o_input_file').attr('accept'), '.dat,.bin',
+ "the input should have the correct ``accept`` attribute");
+ form.destroy();
+ });
+
QUnit.test('binary fields that are readonly in create mode do not download', async function (assert) {
assert.expect(2);
@@ -2414,6 +2430,34 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('image: option accepted_file_extensions', async function (assert) {
+ assert.expect(2);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: ``
+ });
+ assert.strictEqual(form.$('input.o_input_file').attr('accept'), '.png,.jpeg',
+ "the input should have the correct ``accept`` attribute");
+ form.destroy();
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: ``
+ });
+ assert.strictEqual(form.$('input.o_input_file').attr('accept'), 'image/*',
+ 'the default value for the attribute "accept" on the "image" widget must be "image/*"');
+ form.destroy();
+ });
+
QUnit.test('image fields in subviews are loaded correctly', async function (assert) {
assert.expect(6);
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index d9e9b69e6c2..f8c466099e0 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -2317,7 +2317,7 @@ QUnit.module('relational_fields', {
QUnit.module('FieldMany2ManyBinaryMultiFiles');
QUnit.test('widget many2many_binary', async function (assert) {
- assert.expect(15);
+ assert.expect(16);
this.data['ir.attachment'] = {
fields: {
name: {string:"Name", type: "char"},
@@ -2341,7 +2341,7 @@ QUnit.module('relational_fields', {
model: 'turtle',
data: this.data,
arch:'',
archs: {
'ir.attachment,false,list': '',
@@ -2374,6 +2374,9 @@ QUnit.module('relational_fields', {
assert.containsOnce(form, 'div.o_field_widget.oe_fileupload .o_hidden_input_file form',
"there should be a hidden form to upload attachments");
+ assert.strictEqual(form.$('input.o_input_file').attr('accept'), 'image/*',
+ "there should be an attribute \"accept\" on the input")
+
// TODO: add an attachment
// no idea how to test this
diff --git a/doc/reference/javascript_reference.rst b/doc/reference/javascript_reference.rst
index 49ab37cf2e0..bc8b949c80f 100644
--- a/doc/reference/javascript_reference.rst
+++ b/doc/reference/javascript_reference.rst
@@ -1777,6 +1777,9 @@ order.
option is useful to inform the web client that the default field name is
not the name of the current field, but the name of another field.
+ - accepted_file_extensions: the file extension the user can pick from the file input dialog box (default value is 'image/*')
+ (cf: ``accept`` attribute on )
+
.. code-block:: xml
@@ -1786,6 +1789,11 @@ order.
- Supported field types: *binary*
+ Options:
+
+ - accepted_file_extensions: the file extension the user can pick from the file input dialog box
+ (cf: ``accept`` attribute on )
+
Attribute:
- filename: saving a binary file will lose its file name, since it only
@@ -2117,6 +2125,10 @@ Relational fields
- Supported field types: *many2many*
+ Options:
+ - accepted_file_extensions: the file extension the user can pick from the file input dialog box
+ (cf: ``accept`` attribute on )
+
- many2many_tags (FieldMany2ManyTags)
Display many2many as a list of tags.