diff options
| author | Sébastien Theys <seb@odoo.com> | 2018-06-07 15:55:54 +0200 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2018-06-29 10:39:42 +0200 |
| commit | 217fee2636fb4dc4c193e67e5727a9fcef200605 (patch) | |
| tree | d1467195d08c56b45d20d063dc95bc94b1e3ff7e /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | 13667b0dff24449d3c8f9acb33a2153b16c01de7 (diff) | |
[FIX] web: prevent RPC from failing if no route is set
The scenario is:
- create a new parent model, which has a one2many
- add at least 2 one2many lines which have:
- a handle field
- a many2one, which is not required, and we will leave it empty
- reorder the lines with the handle
This will call a resequence, which calls a name_get.
With the bug that would throw an error at the RPC, but this commit fixes it.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 81 |
1 files changed, 73 insertions, 8 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 95b12e9137d..b96e21c2855 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -2540,7 +2540,7 @@ QUnit.module('relational_fields', { $modal.find('thead input[type=checkbox]').click(); $modal.find('.btn.btn-sm.btn-primary.o_select_button').click(); - + pager_limit = form.$('.o_field_many2many.o_field_widget.o_field_x2many.o_field_x2many_list .o_pager_limit'); assert.equal(pager_limit.text(), '51', 'We should have 51 records in the m2m field'); @@ -9074,6 +9074,71 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('one2many with sequence field, fetch name_get from empty list', function (assert) { + // There was a bug where a RPC would fail because no route was set. + // The scenario is: + // - create a new parent model, which has a one2many + // - add at least 2 one2many lines which have: + // - a handle field + // - a many2one, which is not required, and we will leave it empty + // - reorder the lines with the handle + // -> This will call a resequence, which calls a name_get. + // -> With the bug that would fail, if it's ok the test will pass. + assert.expect(4); + + this.data.turtle.fields.turtle_int.default = 10; + this.data.turtle.fields.product_id.default = 37; + this.data.turtle.fields.not_required_product_id = { + string: "Product", + type: "many2one", + relation: 'product' + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'<form string="Partners">' + + '<field name="turtles">' + + '<tree editable="bottom">' + + '<field name="turtle_int" widget="handle"/>' + + '<field name="turtle_foo"/>' + + '<field name="not_required_product_id"/>' + + '</tree>' + + '</field>' + + '</form>', + viewOptions: { + mode: 'edit', + }, + }); + + // starting condition + assert.strictEqual($('.o_data_cell:nth-child(2)').text(), ""); + + var inputText1 = 'relax'; + var inputText2 = 'max'; + form.$('.o_field_x2many_list_row_add a').click(); + form.$('.o_input[name="turtle_foo"]').val(inputText1).trigger('input'); + form.$('.o_field_x2many_list_row_add a').click(); + form.$('.o_input[name="turtle_foo"]').val(inputText2).trigger('input'); + form.$('.o_field_x2many_list_row_add a').click(); + + assert.strictEqual($('.o_data_cell:nth-child(2)').text(), inputText1 + inputText2); + + var $handles = form.$('.ui-sortable-handle'); + + assert.equal($handles.length, 3, 'There should be 3 sequence handlers'); + + testUtils.dragAndDrop($handles.eq(1), + form.$('tbody tr').first(), + {position: 'top'} + ); + + assert.strictEqual($('.o_data_cell:nth-child(2)').text(), inputText2 + inputText1); + + form.destroy(); + }); + QUnit.test('one2many with several pages, onchange and default order', function (assert) { // This test reproduces a specific scenario where a one2many is displayed // over several pages, and has a default order such that a record that @@ -12263,7 +12328,7 @@ QUnit.module('relational_fields', { assert.strictEqual(assert.strictEqual(form.$el.find('.o_field_x2many_list_row_add>a')[0], document.activeElement, "after tab, the focus should be on the many2one on the add new line")); - + form.destroy(); }); @@ -12308,7 +12373,7 @@ QUnit.module('relational_fields', { assert.strictEqual(assert.strictEqual(form.$el.find('input[name="turtle_foo"]')[0], document.activeElement, "after tab, the focus should be on the many2one")); - + form.destroy(); }); @@ -12316,7 +12381,7 @@ QUnit.module('relational_fields', { assert.expect(3); this.data.partner.records[0].turtles = []; - + var form = createView({ View: FormView, model: 'partner', @@ -12360,7 +12425,7 @@ QUnit.module('relational_fields', { assert.strictEqual(assert.strictEqual(form.$el.find('input[name="foo"]')[0], document.activeElement, "after tab, the focus should be on the many2one")); - + form.destroy(); }); @@ -12368,7 +12433,7 @@ QUnit.module('relational_fields', { assert.expect(4); this.data.partner.records[0].turtles = []; - + var form = createView({ View: FormView, model: 'partner', @@ -12422,7 +12487,7 @@ QUnit.module('relational_fields', { assert.strictEqual($.find('input[name="turtle_foo"]')[0], document.activeElement, "after enter, the focus should be in the popup, in the first input field"); - + $('input[name="turtle_foo"]').trigger($.Event('keydown', { which: $.ui.keyCode.ESCAPE, keyCode: $.ui.keyCode.ESCAPE, @@ -12431,7 +12496,7 @@ QUnit.module('relational_fields', { assert.strictEqual(form.$el.find('.o_field_x2many_list_row_add a')[0], document.activeElement, "after escape, the focus should be back on the add new line link"); - + form.destroy(); }); |
