From 3662c7246f90e8a7ea67aa52c71afd0cede330de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sat, 1 Apr 2017 09:36:23 +0200 Subject: [FIX] web: unselect current row on one2many before doing something else In a one2many, when we click on 'Add an item', we need to unselect the current row. Otherwise, its changes will not be committed and it will be in practice discarded. --- .../static/test/fields/relational_fields_tests.js | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'addons/web/static/test/fields/relational_fields_tests.js') diff --git a/addons/web/static/test/fields/relational_fields_tests.js b/addons/web/static/test/fields/relational_fields_tests.js index ac26d523b00..147eb8121de 100644 --- a/addons/web/static/test/fields/relational_fields_tests.js +++ b/addons/web/static/test/fields/relational_fields_tests.js @@ -1177,6 +1177,57 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('one2many list (editable): edition, part 2', function (assert) { + assert.expect(8); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '
', + res_id: 1, + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.strictEqual(args.args[1].p[0][0], 0, + "should send a 0 command for field p"); + assert.strictEqual(args.args[1].p[1][0], 0, + "should send a second 0 command for field p"); + } + return this._super.apply(this, arguments); + }, + }); + + // edit mode, then click on Add an item and enter a value + form.$buttons.find('.o_form_button_edit').click(); + form.$('.o_form_field_x2many_list_row_add a').click(); + form.$('td.o_edit_mode input').val('kartoffel').trigger('input'); + + // click again on Add an item + form.$('.o_form_field_x2many_list_row_add a').click(); + assert.strictEqual(form.$('td:contains(kartoffel)').length, 1, + "should have one td with the new value"); + assert.strictEqual(form.$('td.o_edit_mode input').length, 1, + "should have one other new td"); + assert.strictEqual(form.$('tr.o_data_row').length, 2, "should have 2 data rows"); + + // enter another value and save + form.$('td.o_edit_mode input').val('gemuse').trigger('input'); + form.$buttons.find('.o_form_button_save').click(); + assert.strictEqual(form.$('tr.o_data_row').length, 2, "should have 2 data rows"); + assert.strictEqual(form.$('td:contains(kartoffel)').length, 1, + "should have one td with the new value"); + assert.strictEqual(form.$('td:contains(gemuse)').length, 1, + "should have one td with the new value"); + + form.destroy(); + }); + QUnit.test('onchange in a one2many', function (assert) { assert.expect(1); -- cgit v1.2.3