From 9b9fcfe628f330bf31bfb841476d496e7892153f Mon Sep 17 00:00:00 2001 From: Deep Patel Date: Tue, 12 Sep 2017 18:40:29 +0530 Subject: [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 --- .../web/static/tests/fields/basic_fields_tests.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 9d0d0807199..91029cf9cfc 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -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: '
' + + ' '+ + '', + 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(); + }); }); }); }); -- cgit v1.2.3