[FIX] web: one2many list: quickly switch between pages
Before this rev., a crash might occur when the user quickly switched twice between pages (e.g. go to page 2, then page 3) on a slow network. In the given example, when data of page 2 returned, the list was re-rendered. Unfortunately, the offset of that list' datapoint was already changed due to the switch to page 3, meaning that the view tried to render a page that wasn't loaded yet, leading to a crash if there were modifiers to evaluate, or to empty records being displayed. This rev. ensures that the view is rendered with the data of the page it expects. closes odoo/odoo#30150
This commit is contained in:
@@ -130,8 +130,10 @@ var FieldManagerMixin = {
|
||||
if ('offset' in data) {
|
||||
params.offset = data.offset;
|
||||
}
|
||||
this.model.reload(data.id, params).then(function (db_id) {
|
||||
data.on_success(self.model.get(db_id));
|
||||
this.mutex.exec(function () {
|
||||
return self.model.reload(data.id, params).then(function (db_id) {
|
||||
data.on_success(self.model.get(db_id));
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -10093,6 +10093,48 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('quickly switch between pages in one2many list', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
this.data.partner.records[0].turtles = [1, 2, 3];
|
||||
|
||||
var readDefs = [$.when(), $.Deferred(), $.Deferred()];
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<field name="turtles">' +
|
||||
'<tree limit="1">' +
|
||||
'<field name="display_name"/>' +
|
||||
'</tree>' +
|
||||
'</field>' +
|
||||
'</form>',
|
||||
mockRPC: function (route, args) {
|
||||
var result = this._super.apply(this, arguments);
|
||||
if (args.method === 'read') {
|
||||
var recordID = args.args[0][0];
|
||||
return $.when(readDefs[recordID - 1]).then(_.constant(result));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
res_id: 1,
|
||||
});
|
||||
|
||||
form.$('.o_field_widget[name=turtles] .o_pager_next').click();
|
||||
form.$('.o_field_widget[name=turtles] .o_pager_next').click();
|
||||
|
||||
readDefs[1].resolve();
|
||||
|
||||
assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_data_cell').text(), 'donatello');
|
||||
|
||||
readDefs[2].resolve();
|
||||
|
||||
assert.strictEqual(form.$('.o_field_widget[name=turtles] .o_data_cell').text(), 'raphael');
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.module('FieldMany2Many');
|
||||
|
||||
QUnit.test('many2many kanban: edition', function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user