[FIX] web: fix issue with multiple pages and relational fields
When fetching x2manys in a x2many, the basic model did not properly sort the internal data structure before fetching the data. This is usually not an issue, except when we have an order which is different from the order of the res_ids. In that case, it can cause crash in some conditions, because the results from the fetchx2manybatched were applied to the wrong datapoint. To reproduce this issue, some specific conditions needs to be met. I think that it is easier to refer to the test, instead of trying to explain that. In this commit, we properly sort the data at the correct place. Note that this probably solves a bunch of other related issues, caused by the fact that the internal structure was corrupted.
This commit is contained in:
@@ -2374,7 +2374,7 @@ var BasicModel = AbstractModel.extend({
|
||||
});
|
||||
record.data[fieldName] = list.id;
|
||||
if (!fieldInfo.__no_fetch) {
|
||||
var def = self._readUngroupedList(list).then(function (list) {
|
||||
var def = self._readUngroupedList(list).then(function () {
|
||||
return $.when(
|
||||
self._fetchX2ManysBatched(list),
|
||||
self._fetchReferencesBatched(list)
|
||||
@@ -2403,6 +2403,7 @@ var BasicModel = AbstractModel.extend({
|
||||
var fields = view ? view.fields : fieldInfo.relatedFields;
|
||||
var viewType = view ? view.type : fieldInfo.viewType;
|
||||
list = this._applyX2ManyOperations(list);
|
||||
this._sortList(list);
|
||||
var x2mRecords = [];
|
||||
|
||||
// step 1: collect ids
|
||||
|
||||
@@ -7640,6 +7640,46 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('one2many with multiple pages and sequence field, part2', 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 id2", partner_ids: [[5]]}],
|
||||
[1, 3, {turtle_foo: "from onchange id3", 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 id2from onchange id3',
|
||||
'onchange has been properly applied');
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.module('FieldMany2Many');
|
||||
|
||||
QUnit.test('many2many kanban: edition', function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user