diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-04-01 09:36:23 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 3662c7246f90e8a7ea67aa52c71afd0cede330de (patch) | |
| tree | f33e760477f85f5326e32afe7e877ac8054aa07e /addons/web/static/test | |
| parent | 7056ec1ac6e6c23231d9044bb60efc2a0bdb7ae2 (diff) | |
[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.
Diffstat (limited to 'addons/web/static/test')
| -rw-r--r-- | addons/web/static/test/fields/relational_fields_tests.js | 51 |
1 files changed, 51 insertions, 0 deletions
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: '<form string="Partners">' + + '<field name="p">' + + '<tree editable="top">' + + '<field name="foo"/>' + + '</tree>' + + '</field>' + + '</form>', + 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); |
