From 7d448d57e34511eb668a695e9238a2096c05411e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 11 Oct 2017 08:55:03 +0200 Subject: [FIX] web: fix issue with default_get/onchange and one2many Before this commit, there was a bug when creating a new record which contains a one2many with an onchange. The commands sent to the onchange did not contain the full information. Here is how you could reproduce the issue: install expense, go to the expense list view, select the 2 lines, then, in the 'action' menu in the control panel, choose 'Expense: submit to manager'. In the new expense sheet, you could see that there were two lines in the one2many expense_line_ids. However, these lines are empty. The reason is that the commands sent in the onchange were 2 commands 0, with {} as data. So, in short, the BasicModel did generate the proper commands, but with empty data, in the specific case when we have a non empty one2many in a default_get, then an onchange. To solve this issue, I had to fix 2 things: the internal data struture was wrongly updated, and the commands should be generated with all the data, and not only the changes. --- .../static/tests/fields/relational_fields_tests.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index cfa6726f429..d019bbd63ca 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -1061,6 +1061,44 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('list in form: default_get with x2many create and onchange', function (assert) { + assert.expect(1); + + this.data.partner.onchanges.turtles = function (obj) { + assert.deepEqual( + obj.turtles, + [ + [0, false, {turtle_foo: 'blip', id: 2}], + [0, false, {turtle_foo: 'kawa', id: 3}] + ], + "should have properly created the x2many command list"); + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + mockRPC: function (route, args) { + if (args.method === 'default_get') { + return $.when({turtles: [[6, 0, [2,3]]]}); + } + return this._super.apply(this, arguments); + }, + }); + + form.destroy(); + }); + QUnit.test('list in form: call button in sub view', function (assert) { assert.expect(6); -- cgit v1.2.3 From 66b692a5eb2350a8c22e9be0b05f08b8b7f6ae9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 12 Oct 2017 10:27:27 +0200 Subject: [FIX] web: fix display issue with fieldSelection When displaying a many2one values, in edit mode, the option did not properly display some characters. --- .../static/tests/fields/relational_fields_tests.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index d019bbd63ca..bead59b5cd3 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -7044,6 +7044,26 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('field selection with many2ones and special characters', function (assert) { + assert.expect(1); + + // edit the partner with id=4 + this.data.partner.records[2].display_name = 'hey'; + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + viewOptions: {mode: 'edit'}, + }); + assert.strictEqual(form.$('select option[value="4"]').text(), 'hey'); + + form.destroy(); + }); + QUnit.test('widget selection on a many2one: domain updated by an onchange', function (assert) { assert.expect(4); -- cgit v1.2.3 From d4cf4374d1baa529bb651bb3cc32e9db140963a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 12 Oct 2017 09:46:55 +0200 Subject: [FIX] web: allow widget many2many_tags to display more than 40 records Before this commit, the widget many2many_tags only loaded the first 40 records. This was difficult to see, because there were not so many views with a lot of tags. --- .../static/tests/fields/relational_fields_tests.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index bead59b5cd3..5d5e22e386e 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -7451,6 +7451,29 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('many2many_tags can load more than 40 records', function (assert) { + assert.expect(1); + + this.data.partner.fields.partner_ids = {string: "Partner", type: "many2many", relation: 'partner'}; + this.data.partner.records[0].partner_ids = []; + for (var i = 15; i < 115; i++) { + this.data.partner.records.push({id: i, display_name: 'walter' + i}); + this.data.partner.records[0].partner_ids.push(i); + } + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + }); + assert.strictEqual(form.$('.o_field_widget[name="partner_ids"] > span').length, 100, + 'should have rendered 100 tags'); + form.destroy(); + }); + QUnit.test('field many2many_tags keeps focus when being edited', function (assert) { assert.expect(7); -- cgit v1.2.3