From 8191d6d72e82282c3ea4547d02bfd6ee9fa5022b Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Thu, 12 Oct 2017 17:42:18 +0200 Subject: [FIX] web: tab navigation with phone widgets in form view This commit ensures that tab navigation works properly when editing a form view that contains input fields with phone widgets. Previously, pressing TAB would skip those fields. --- .../web/static/tests/fields/basic_fields_tests.js | 27 ++++++++++++++++++++++ 1 file changed, 27 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 0dd11e549bd..b7d78afda73 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -2771,6 +2771,33 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('use TAB to navigate to a phone field', function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + }); + + form.$('input[name=display_name]').click(); + assert.strictEqual(form.$('input[name="display_name"]')[0], document.activeElement, + "display_name should be focused"); + form.$('input[name="display_name"]').trigger($.Event('keydown', {which: $.ui.keyCode.TAB})); + assert.strictEqual(form.$('input[name="foo"]')[0], document.activeElement, + "foo should be focused"); + + form.destroy(); + }); + QUnit.module('PriorityWidget'); QUnit.test('priority widget when not set', function (assert) { -- cgit v1.2.3 From 841f41f95b7cf7d8f13ddce724d60d1d1149886d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 18 Oct 2017 18:02:44 +0200 Subject: [FIX] web: domain field should never be considered unset Indeed, false was already considered as "[]" in edit mode. --- addons/web/static/tests/fields/basic_fields_tests.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (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 b7d78afda73..ada39fe3a29 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1957,7 +1957,7 @@ QUnit.module('basic_fields', { QUnit.test('datetime field with date/datetime widget (with day change)', function (assert) { assert.expect(2); - + this.data.partner.records[0].p = [2]; this.data.partner.records[1].datetime = "2017-02-08 02:00:00"; // UTC @@ -3786,7 +3786,7 @@ QUnit.module('basic_fields', { }); QUnit.test('domain field: handle false domain as []', function (assert) { - assert.expect(2); + assert.expect(3); this.data.partner.records[0].foo = false; this.data.partner.fields.bar.type = "char"; @@ -3812,11 +3812,13 @@ QUnit.module('basic_fields', { return this._super.apply(this, arguments); }, res_id: 1, - viewOptions: { - mode: 'edit', - }, }); + assert.strictEqual(form.$('.o_field_widget[name=foo]:not(.o_field_empty)').length, 1, + "there should be a domain field, not considered empty"); + + form.$buttons.find('.o_form_button_edit').click(); + var $warning = form.$('.o_field_widget[name=foo] .text-warning'); assert.strictEqual($warning.length, 0, "should not display that the domain is invalid"); -- cgit v1.2.3 From 1312ee72cf35e3887721ac56472f1188f636ec61 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Thu, 19 Oct 2017 12:00:50 +0200 Subject: [FIX] web: correctly render the field image Before this commit, the image was directly built without using the corresponding template, which set some properties on the image (class, width, etc.). --- .../web/static/tests/fields/basic_fields_tests.js | 36 ++++++++++++++++++++++ 1 file changed, 36 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 ada39fe3a29..1e3233128d6 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1424,6 +1424,42 @@ QUnit.module('basic_fields', { } }); + QUnit.module('FieldImage'); + + QUnit.test('image fields are correctly rendered', function (assert) { + assert.expect(5); + + this.data.partner.records[0].document = 'myimage'; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + ' ' + + '', + res_id: 1, + mockRPC: function (route) { + if (route === 'data:image/png;base64,myimage') { + assert.ok(true, "should called the correct route"); + return $.when('wow'); + } + return this._super.apply(this, arguments); + }, + }); + + assert.ok(form.$('div[name="document"]').hasClass('o_field_image'), + "the widget should have the correct class"); + assert.strictEqual(form.$('div[name="document"] > img').length, 1, + "the widget should contain an image"); + assert.ok(form.$('div[name="document"] > img').hasClass('img-responsive'), + "the image should have the correct class"); + assert.strictEqual(form.$('div[name="document"] > img').attr('width'), "90", + "the image should correctly set its attributes"); + form.destroy(); + + }); + QUnit.module('JournalDashboardGraph'); QUnit.test('graph dashboard widget is rendered correctly', function (assert) { -- cgit v1.2.3 From 2455350c40df86266eabd614ceab451159d67be3 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Thu, 19 Oct 2017 18:05:17 +0200 Subject: [FIX] web: deal with `date` widget on datetime This use case was not correctly managed as the function evaluating if the value has changed compares datetime and date. This triggered an issue if the widget `date` was set on the field `date_order` on a purchase order for example ; it was not possible to create a record as the datapoint was set `dirty`. This rev. ensures that a `field_changed` is not triggered if the day is the same on a date widget. This rev. also adds support of `datetime` fields on date widget, which appears to be a valid use case. Fixes https://github.com/odoo/odoo/issues/20311 --- .../web/static/tests/fields/basic_fields_tests.js | 33 ++++++++++++++++++++++ 1 file changed, 33 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 1e3233128d6..f05d7abf08e 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1823,6 +1823,39 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('do not trigger a field_changed for datetime field with date widget', function (assert) { + assert.expect(3); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
', + translateParameters: { // Avoid issues due to localization formats + date_format: '%m/%d/%Y', + time_format: '%H:%M:%S', + }, + res_id: 1, + viewOptions: { + mode: 'edit', + }, + mockRPC: function (route, args) { + assert.step(args.method); + return this._super.apply(this, arguments); + }, + }); + + assert.strictEqual(form.$('.o_datepicker_input').val(), '02/08/2017', + 'the date should be correct'); + + form.$('input[name="datetime"]').val('02/08/2017').trigger('input').trigger('change'); + form.$buttons.find('.o_form_button_save').click(); + + assert.verifySteps(['read']); // should not have save as nothing changed + + form.destroy(); + }); + QUnit.module('FieldDatetime'); QUnit.test('datetime field in form view', function (assert) { -- cgit v1.2.3