[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.
This commit is contained in:
Martin Geubelle
2017-05-24 08:25:23 +02:00
committed by Aaron Bohy
parent 460c21f765
commit fc82e1e40a
2 changed files with 7 additions and 3 deletions
+4 -2
View File
@@ -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>
+3 -1
View File
@@ -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();
});