[FIX] web,base: document template widget in settings

Go to General Settings, click on 'Change Document Template', and
in the opened dialog, click on a template.

Before this rev., it automatically closed the dialog, which was
not really convenient.

This rev. introduces a new field widget (image_selection) for
this use case, and ensures that the dialog doesn't close when
a template is selected.

Test written by @mba-odoo
This commit is contained in:
Deep Patel
2017-09-20 10:56:57 +02:00
committed by Aaron Bohy
parent 48b8be29fa
commit 9b9fcfe628
5 changed files with 111 additions and 46 deletions
@@ -38,6 +38,8 @@ QUnit.module('basic_fields', {
selection: {string: "Selection", type: "selection", searchable:true,
selection: [['normal', 'Normal'],['blocked', 'Blocked'],['done', 'Done']]},
document: {string: "Binary", type: "binary"},
image_selection: {string: "Image Selection", type: "selection", searchable:true,
selection: [['background', 'Background'],['boxed', 'Boxed'],['clean', 'Clean'],['standard', 'Standard']]},
},
records: [{
id: 1,
@@ -3995,6 +3997,45 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.module('FieldImageSelection');
QUnit.test('image selection widget in form view', function (assert) {
assert.expect(3);
var nodeOptions = {
background: {
image_link: '/base/static/img/preview_background.png',
preview_link: '/base/static/pdf/preview_background.pdf',
},
boxed: {
image_link: '/base/static/img/preview_boxed.png',
preview_link: '/base/static/pdf/preview_boxed.pdf',
},
};
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<field name="image_selection" widget="image_selection"' +
' options=\'' + JSON.stringify(nodeOptions) + '\'/> '+
'</form>',
res_id: 2,
});
assert.strictEqual(form.$('.img.img-responsive').length, 2,
"Two images should be rendered");
assert.strictEqual(form.$('.img.btn-info').length, 0,
"No image should be selected");
// select first image
form.$(".img.img-responsive:first").click();
assert.ok(form.$(".img.img-responsive:first").hasClass('btn-info'),
"First image should be selected");
form.destroy();
});
});
});
});