diff options
| author | Martin Geubelle <mge@odoo.com> | 2017-05-19 17:25:59 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-24 08:25:23 +0200 |
| commit | fc82e1e40abd8092e6a044dc4e78432beffb5149 (patch) | |
| tree | 1000b8c86df671f84f9446655443155dd59f2031 | |
| parent | 460c21f76578cceec364f0431d03e4f4515d6acc (diff) | |
[FIX] mrp: correctly replace inputs in pdf_viewer widget
In the extended template `HiddenInputFile` there are actually two inputs
(one for image only and another one).
This widget needs to replace both of them otherwise the file selector will
be opened twice.
| -rw-r--r-- | addons/mrp/static/src/xml/mrp.xml | 6 | ||||
| -rw-r--r-- | addons/mrp/static/tests/mrp_tests.js | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/addons/mrp/static/src/xml/mrp.xml b/addons/mrp/static/src/xml/mrp.xml index 54b1bb6fc9b..5a1c9353084 100644 --- a/addons/mrp/static/src/xml/mrp.xml +++ b/addons/mrp/static/src/xml/mrp.xml @@ -16,8 +16,10 @@ </div> </t> <t t-extend="HiddenInputFile" t-name="HiddenInputPDFFile"> - <t t-jquery="input[type='file']:first" t-operation="replace"> - <input type="file" class="o_input_file" name="ufile" accept="application/pdf" /> + <!-- remove the inputs and put a new one for pdf only --> + <t t-jquery="input[type='file']" t-operation="replace"/> + <t t-jquery="form" t-operation="append"> + <input type="file" class="o_input_file" name="ufile" accept="application/pdf"/> </t> </t> </templates> diff --git a/addons/mrp/static/tests/mrp_tests.js b/addons/mrp/static/tests/mrp_tests.js index ed4dab4f91b..40f6fc2607b 100644 --- a/addons/mrp/static/tests/mrp_tests.js +++ b/addons/mrp/static/tests/mrp_tests.js @@ -31,7 +31,7 @@ QUnit.module('mrp', { }, }, function () { QUnit.test("pdf_viewer without data", function (assert) { - assert.expect(3); + assert.expect(4); var form = createView({ View: FormView, @@ -48,6 +48,8 @@ QUnit.module('mrp', { "there should be a visible 'Upload' button"); assert.ok(form.$('.o_field_widget iframe.o_pdfview_iframe').hasClass('o_hidden'), "there should be an invisible iframe"); + assert.strictEqual(form.$('input[type="file"]').length, 1, + "there should be one input"); form.destroy(); }); |
