From 9e6c616130622eabc5a43f84eca80c6326ded20b Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 11 Apr 2018 17:19:45 +0200 Subject: [FIX] web: focus select in reference widget In the reference widget, the focus was always on the input (many2one) even though the first select (with the model) was not set. Thanks to @kaerdsar for the original PR. Partially closes #24070 --- .../static/tests/fields/relational_fields_tests.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index b855f827c97..b28ddfafb0a 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -11298,6 +11298,32 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('reference and list navigation', function (assert) { + assert.expect(2); + + var list = createView({ + View: ListView, + model: 'partner', + data: this.data, + arch: '', + }); + + // edit first row + list.$('.o_data_row .o_data_cell').first().click(); + assert.strictEqual(list.$('.o_data_row:eq(0) .o_field_widget[name="reference"] input')[0], document.activeElement, + 'input of first data row should be selected'); + + // press TAB to go to next line + list.$('.o_data_row:eq(0) input').trigger($.Event('keydown', { + which: $.ui.keyCode.TAB, + keyCode: $.ui.keyCode.TAB, + })); + assert.strictEqual(list.$('.o_data_row:eq(1) .o_field_widget[name="reference"] select')[0], document.activeElement, + 'select of second data row should be selected'); + + list.destroy(); + }); + QUnit.test('one2many with extra field from server not in form', function (assert) { assert.expect(6); -- cgit v1.2.3 From cd934f307de19b247bf88b9dc41a8fdea15fd23c Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Tue, 17 Apr 2018 11:46:12 +0200 Subject: [FIX] web: handle x2m commands with reference as default Before this rev. it was not possible to define a value for a reference field in x2m commands as default value. Courtesy of @kaerdsar. Closes #24070 --- .../static/tests/fields/relational_fields_tests.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index b28ddfafb0a..8fb1780489a 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -11248,6 +11248,38 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('default_get a reference field in a x2m', function (assert) { + assert.expect(1); + + this.data.partner.fields.turtles.default = [ + [0, false, {turtle_ref: 'product,37'}] + ]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + viewOptions: { + mode: 'edit', + }, + archs: { + 'turtle,false,form': '
', + }, + }); + assert.strictEqual(form.$('.o_field_one2many[name="turtles"] .o_data_row:first').text(), "xphone", + "the default value should be correctly handled"); + form.destroy(); + }); + QUnit.test('widget reference on char field, reset by onchange', function (assert) { assert.expect(4); -- cgit v1.2.3 From 05589db8232a68846cca2660c73914045b1fec5a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 13 Apr 2018 15:22:47 +0200 Subject: [FIX] web: don't ignore required attrs on image fields Before this rev., falsy image fields could be saved even if they were required. --- .../web/static/tests/fields/basic_fields_tests.js | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 909e778b60a..7f1742b3041 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1698,7 +1698,6 @@ QUnit.module('basic_fields', { assert.strictEqual(form.$('div[name="document"] > img').attr('width'), "90", "the image should correctly set its attributes"); form.destroy(); - }); QUnit.test('image fields in subviews are loaded correctly', function (assert) { @@ -1750,6 +1749,34 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('image fields with required attribute', function (assert) { + assert.expect(2); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '', + mockRPC: function (route, args) { + if (args.method === 'create') { + throw new Error("Should not do a create RPC with unset required image field"); + } + return this._super.apply(this, arguments); + }, + }); + + form.$buttons.find('.o_form_button_save').click(); + + assert.ok(form.$('.o_form_view').hasClass('o_form_editable'), + "form view should still be editable"); + assert.ok(form.$('.o_field_widget').hasClass('o_field_invalid'), + "image field should be displayed as invalid"); + + form.destroy(); + }); + QUnit.module('JournalDashboardGraph', { beforeEach: function () { _.extend(this.data.partner.fields, { -- cgit v1.2.3