From e981e3312d66cd6fcddef05feda0f49b37a4c858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Debauche=20St=C3=A9phane?= Date: Thu, 10 Oct 2019 12:39:25 +0000 Subject: [IMP] web: many2many_binary, binary, image, add the option ``accepted_file_extensions`` Purpose ======= We want to add an option on the widgets - many2many_binary, - binary, - image This option specifies what file extensions the user can pick from the file input dialog box. Examples ======== ```xml ``` How === Add an option (accepted_file_extensions) in the template ``HiddenInputFile`` (the widget many2many_binary is using this template) So, we can also use this new option in others widgets using ``HiddenInputFile`` In the many2many_binary, read the ``nodeOptions`` and set the widget attribute ``accepted_file_extensions`` We also have to fix some other widget, because an property ``image_only`` was already existing in the template ``HiddenInputFile`` (we just need to replace ``image_only=True`` to ``accepted_file_extensions='image/*'`` The widget ``FieldPdfViewer`` (pdf_viewer) now use the new option to filtrate PDF (instead of removing the and adding ). Tests ===== We also test if the option is correctly set on the - binary - image - many2many_binary Impacted widgets =============== - many2many_binary - image: this widget use ``options="{accepted_file_extensions='image/*'}"`` instead of ``image_only=True`` - tablet_image: same as ``image`` Task #2082815 closes odoo/odoo#38351 Signed-off-by: VincentSchippefilt --- addons/web/static/tests/fields/relational_fields_tests.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') 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 -- cgit v1.2.3