Skip to content

Commit

Permalink
[FIX] web: fallback orderedBy from datapoint
Browse files Browse the repository at this point in the history
Have a list/kanban with a default_order on the view
Have a default filter that applies

Click on a element of the list
Go back to the list with the breadcrumbs

Before this commit, the default_order was not applied
This is because the wrong check was made to determine the orderedBy of the model

After this commit, the previous order that has been set on the model is kept
when reloading the model

OPW 1922576
  • Loading branch information
kebeclibre committed Feb 22, 2019
1 parent 64a3d8f commit 4254899
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion addons/web/static/src/js/views/basic/basic_model.js
Expand Up @@ -4030,7 +4030,8 @@ var BasicModel = AbstractModel.extend({


if (options.context !== undefined) { if (options.context !== undefined) {
element.context = options.context; element.context = options.context;
element.orderedBy = options.context.orderedBy || element.orderedBy; element.orderedBy =
options.context.orderedBy && options.context.orderedBy.length ? options.context.orderedBy : element.orderedBy;
} }
if (options.domain !== undefined) { if (options.domain !== undefined) {
element.domain = options.domain; element.domain = options.domain;
Expand Down
12 changes: 11 additions & 1 deletion addons/web/static/tests/views/list_tests.js
Expand Up @@ -346,7 +346,7 @@ QUnit.module('Views', {
}); });


QUnit.test('Loading a filter with a sort attribute', function (assert) { QUnit.test('Loading a filter with a sort attribute', function (assert) {
assert.expect(2); assert.expect(3);


this.data.foo.fields.foo.sortable = true; this.data.foo.fields.foo.sortable = true;
this.data.foo.fields.date.sortable = true; this.data.foo.fields.date.sortable = true;
Expand Down Expand Up @@ -377,6 +377,9 @@ QUnit.module('Views', {
} else if (searchReads === 1) { } else if (searchReads === 1) {
assert.strictEqual(args.sort, 'date DESC, foo ASC', assert.strictEqual(args.sort, 'date DESC, foo ASC',
'The sort attribute of the filter should be used by the next search_read'); 'The sort attribute of the filter should be used by the next search_read');
} else if (searchReads === 2) {
assert.strictEqual(args.sort, 'date DESC, foo ASC',
'The sort attribute on the element should be used by the next search_read');
} }
searchReads += 1; searchReads += 1;
} }
Expand All @@ -397,6 +400,13 @@ QUnit.module('Views', {
} }
}); });


// Simulates going back to the list with breadcrumbs
list.update({
context: {
orderedBy: []
}
});

list.destroy() list.destroy()
}); });


Expand Down

0 comments on commit 4254899

Please sign in to comment.