Skip to content
Permalink
Browse files

[FIX] web: update domain when switching between views

Let's assume the following scenario on an action with two multi
records views (e.g. kanban and list). In the kanban view, activate
a domain or groupby, switch to list view, remove the domain or
groupby, switch back to kanban: the domain or groupby is still
applied (even though it's no longer displayed in the search view).

This is due to the jQuery update (ab56e63) and the use of
native Promises (always async) instead of old jQuery 1.11 Deferreds
(which where sync when already resolved). In the new version, the
domain/context/groupby were added to the params a 'tick too late',
so the view was updated without that information (and thus the old
domain/context/groupby were kept).

Issue reported on the jquery update pad.
  • Loading branch information...
aab-odoo committed Mar 14, 2019
1 parent 7282a35 commit 1ecf05a77982144cfb01921d7e227bb9f95b6d2b
@@ -182,6 +182,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
*/
reload: function (params) {
params = params || {};
var self = this;
var def;
var controllerState = params.controllerState || {};
var cpState = controllerState.cpState;
@@ -190,7 +191,9 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
params = _.extend({}, params, searchQuery);
});
}
return Promise.resolve(def).then(this.update.bind(this, params, {}));
return Promise.resolve(def).then(function () {
self.update(params, {});
});
},
/**
* For views that require a pager, this method will be called to allow the
@@ -2208,7 +2208,7 @@ QUnit.module('ActionManager', {
QUnit.test('orderedBy in context is not propagated when executing another action', async function (assert) {
assert.expect(6);

this.data.partner.fields.foo.sortable = true,
this.data.partner.fields.foo.sortable = true;

this.archs['partner,false,form'] = '<header>' +
'<button name="8" string="Execute action" type="action"/>' +
@@ -2422,6 +2422,40 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});

QUnit.test("domain is kept when switching between views", async function (assert) {
assert.expect(5);

this.actions[2].search_view_id = [1, 'a custom search view'];

var actionManager = await createActionManager({
actions: this.actions,
archs: this.archs,
data: this.data,
});

await actionManager.doAction(3);
assert.containsN(actionManager, '.o_data_row', 5);

// activate a domain
await testUtils.dom.click(actionManager.$('.o_search_options .o_filters_menu_button'));
await testUtils.dom.click(actionManager.$('.o_search_options .o_filters_menu a:contains(Bar)'));
assert.containsN(actionManager, '.o_data_row', 2);

// switch to kanban
await testUtils.dom.click(actionManager.$('.o_control_panel .o_cp_switch_kanban'));
assert.containsN(actionManager, '.o_kanban_record:not(.o_kanban_ghost)', 2);

// remove the domain
await testUtils.dom.click(actionManager.$('.o_searchview .o_facet_remove'));
assert.containsN(actionManager, '.o_kanban_record:not(.o_kanban_ghost)', 5);

// switch back to list
await testUtils.dom.click(actionManager.$('.o_control_panel .o_cp_switch_list'));
assert.containsN(actionManager, '.o_data_row', 5);

actionManager.destroy();
});

QUnit.test('there is no flickering when switching between views', async function (assert) {
assert.expect(20);

0 comments on commit 1ecf05a

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.