[FIX] web: load more with progressbar load more

Be in a grouped kanban view with progressbar with limit 10:

- records 1 to 10 are loaded on a column
- do "Load more..." on a column => records 11 up to 20 are loaded
- do "Load more..." 2nd time => records 11 up to 20 are loaded
- do "Load more..." 3rd time => records 11 up to 20 are loaded
- ...

While in reality it should be:
- do "Load more..." 2nd time => records 21 up to 30 are loaded
- do "Load more..." 3rd time => records 31 up to 40 are loaded
- ...

This was caused by the progressbar reloading the column's group. This
set the loadMoreOffset to 0 thus forgetting the current state.

Without the change, added tests failed with:

 records of column are loaded => actual: "1,2,2", expected: "1,2,3"

opw-1878359
closes #26628
This commit is contained in:
Nicolas Lempereur
2018-09-03 15:58:52 +02:00
parent 98665aca1c
commit 388eff5b58
2 changed files with 34 additions and 0 deletions
@@ -222,6 +222,9 @@ var KanbanModel = BasicModel.extend({
options.groupBy = this.defaultGroupedBy;
}
var def = this._super(id, options);
if (options && options.loadMoreOffset) {
return def;
}
return this._reloadProgressBarGroupFromRecord(id, def);
},
/**
@@ -2557,6 +2557,37 @@ QUnit.module('Views', {
kanban.destroy();
});
QUnit.test('column progressbars are working with load more', function (assert) {
assert.expect(1);
var kanban = createView({
View: KanbanView,
model: 'partner',
data: this.data,
domain: [['bar', '=', true]],
arch:
'<kanban limit="1">' +
'<progressbar field="foo" colors=\'{"yop": "success", "gnap": "warning", "blip": "danger"}\'/>' +
'<templates><t t-name="kanban-box">' +
'<div>' +
'<field name="id"/>' +
'</div>' +
'</t></templates>' +
'</kanban>',
groupBy: ['bar'],
});
// we have 1 record shown, load 2 more and check it worked
kanban.$('.o_kanban_group').find('.o_kanban_load_more').click();
kanban.$('.o_kanban_group').find('.o_kanban_load_more').click();
var shownIDs = _.map(kanban.$('.o_kanban_record'), function(record) {
return parseInt(record.innerText);
});
assert.deepEqual(shownIDs, [1, 2, 3], "intended records are loaded");
kanban.destroy();
});
QUnit.test('column progressbars on archiving records update counter', function (assert) {
assert.expect(4);