[FIX] web: exclude orderedBy when changing action

When activating a filter on a list view,
the environment of the action contained a context with an orderedBy key
which was then used by every controller and model in the various
parallel flows, i.e. changing actions

After this commit, we prevent it by excluding the key when executing an action

OPW 1913190, 1914019

closes #29190
This commit is contained in:
Lucas Perais (lpe)
2018-12-05 14:21:44 +01:00
parent d4c65a7ede
commit f32cdb5ccf
2 changed files with 57 additions and 1 deletions
@@ -764,7 +764,7 @@ ActionManager.include({
_.object(_.reject(_.pairs(env.context), function (pair) {
return pair[0].match('^(?:(?:default_|search_default_|show_).+|' +
'.+_view_ref|group_by|group_by_no_leaf|active_id|' +
'active_ids)$') !== null;
'active_ids|orderedBy)$') !== null;
}))
);
ctx.add(actionData.context || {});
@@ -2079,6 +2079,62 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
QUnit.test('orderedBy in context is not propagated when executing another action', function (assert) {
assert.expect(6);
this.data.partner.fields.foo.sortable = true,
this.archs['partner,false,form'] = '<header>' +
'<button name="8" string="Execute action" type="action"/>' +
'</header>';
var searchReadCount = 0;
var actionManager = createActionManager({
actions: this.actions,
archs: this.archs,
data: this.data,
mockRPC: function (route, args) {
if (route === '/web/dataset/search_read') {
if (searchReadCount === 1) {
assert.strictEqual(args.model, 'partner');
assert.notOk(args.sort);
}
if (searchReadCount === 2) {
assert.strictEqual(args.model, 'partner');
assert.strictEqual(args.sort, "foo ASC");
}
if (searchReadCount === 3) {
assert.strictEqual(args.model, 'pony');
assert.notOk(args.sort);
}
searchReadCount += 1;
}
return this._super.apply(this, arguments);
},
});
actionManager.doAction(3);
// Simulate the activation of a filter
var searchData = {
domains: [[["foo", "=", "yop"]]],
contexts: [{
orderedBy: [],
}],
};
actionManager.trigger_up('search', searchData);
// Sort records
actionManager.$('.o_list_view th.o_column_sortable').click();
// get to the form view of the model, on the first record
actionManager.$('.o_data_cell:first').click();
// Change model by clicking on the button within the form
actionManager.$('.o_form_view button').click();
actionManager.destroy();
});
QUnit.test('breadcrumbs are updated when switching between views', function (assert) {
assert.expect(10);