diff options
| author | Géry Debongnie <ged@odoo.com> | 2018-01-11 15:24:56 +0100 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2018-01-11 16:30:34 +0100 |
| commit | 27dd19c0b9b5ccdf1e84509119ace6becb09ff6d (patch) | |
| tree | 26f2b6df122babcea873f2916234f4b1313da560 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | 8dcee7f17e060b4df3e2e22584e8110923168e85 (diff) | |
[FIX] web: prevent crash in some rare cases
When we have a form view with a one2many with an onchange, and with
lines which contains a x2many, and more lines that the limit (so more
than one page), and the read is not in the same order as what is
displayed because we have a widget=handle, then we might have a problem
when we delete one of the lines, if the onchanges tries to change the
x2many.
This is due to the fact that the order of the basicmodel datapoint is
not preserved by the various operations going around. I think that we
may still have a few other issues of this type, but it is actually quite
difficult to establish.
In any case, this situation is now properly handled.
opw 804530
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index de114bac9cf..a157577594c 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -7600,6 +7600,46 @@ QUnit.module('relational_fields', { form.destroy(); }); + + QUnit.test('one2many with multiple pages and sequence field', function (assert) { + assert.expect(1); + + this.data.partner.records[0].turtles = [3, 2, 1]; + this.data.partner.onchanges.turtles = function () {}; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'<form string="Partners">' + + '<field name="turtles">' + + '<tree limit="2">' + + '<field name="turtle_int" widget="handle"/>' + + '<field name="turtle_foo"/>' + + '<field name="partner_ids" invisible="1"/>' + + '</tree>' + + '</field>' + + '</form>', + res_id: 1, + mockRPC: function (route, args) { + if (args.method === 'onchange') { + return $.when({value: { turtles: [ + [5], + [1, 1, {turtle_foo: "from onchange", partner_ids: [[5]]}], + ]}}); + } + return this._super(route, args); + }, + viewOptions: { + mode: 'edit', + }, + }); + form.$('span[name="delete"]').first().click(); + assert.strictEqual(form.$('.o_data_row').text(), 'from onchange', + 'onchange has been properly applied'); + form.destroy(); + }); + QUnit.module('FieldMany2Many'); QUnit.test('many2many kanban: edition', function (assert) { |
