[FIX] web: reload search panel before view model
Problem: Go to the application apps, select accounting in the search panel, then filter on lunch in the search bar: the category all is displayed as selected in the search panel (accounting is no more a valid value since expand="0") but the application lunch does not appear in the kanban view. Root cause: The kanban model is reloaded with the old domain using accounting without waiting the search panel to be reloaded but it is only known after the search panel has been reloaded that the accounting value is no more valid and that all should be selected instead of accounting, thus that the domain used by the kanban model should be updated. Solution: The solution to the problem is simple: first reload the search panel, then reload the view model with the updated domain. X-original-commit: 8589babcd0f2c15433fe1eb06d0d745e80d01c22
This commit is contained in:
@@ -211,7 +211,6 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
reload: async function (params = {}) {
|
||||
let searchPanelUpdateProm;
|
||||
const controllerState = params.controllerState || {};
|
||||
const cpState = controllerState.cpState;
|
||||
if (this.withControlPanel && cpState) {
|
||||
@@ -226,19 +225,19 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
|
||||
}
|
||||
if (controllerState.spState) {
|
||||
this._searchPanel.importState(controllerState.spState);
|
||||
this.searchPanelDomain = this._searchPanel.getDomain();
|
||||
} else {
|
||||
const viewDomain = await this._getViewDomain();
|
||||
searchPanelUpdateProm = this._searchPanel.update({
|
||||
await this._searchPanel.update({
|
||||
searchDomain: this.controlPanelDomain,
|
||||
viewDomain,
|
||||
});
|
||||
postponeRendering = !params.noRender;
|
||||
params.noRender = true; // wait for searchpanel to be ready to render
|
||||
}
|
||||
this.searchPanelDomain = this._searchPanel.getDomain();
|
||||
params.domain = this.controlPanelDomain.concat(this.searchPanelDomain);
|
||||
}
|
||||
await Promise.all([this.update(params, {}), searchPanelUpdateProm]);
|
||||
await this.update(params, {});
|
||||
if (postponeRendering) {
|
||||
return this._updateRendererState(false);
|
||||
}
|
||||
|
||||
@@ -491,10 +491,11 @@ QUnit.module('Views', {
|
||||
var Storage = RamStorage.extend({
|
||||
getItem: function (key) {
|
||||
assert.step('getItem ' + key);
|
||||
return 3; // 'asustek'
|
||||
return this._super(...arguments) || 3; // default: 'asustek'
|
||||
},
|
||||
setItem: function (key, value) {
|
||||
assert.step('setItem ' + key + ' to ' + value);
|
||||
this._super(...arguments);
|
||||
},
|
||||
});
|
||||
var RamStorageService = AbstractStorageService.extend({
|
||||
@@ -2673,8 +2674,8 @@ QUnit.module('Views', {
|
||||
|
||||
assert.verifySteps([
|
||||
'search_panel_select_range',
|
||||
'/web/dataset/search_read',
|
||||
"search_panel_select_multi_range"
|
||||
"search_panel_select_multi_range",
|
||||
'/web/dataset/search_read'
|
||||
]);
|
||||
|
||||
kanban.destroy();
|
||||
@@ -3993,5 +3994,77 @@ QUnit.module('Views', {
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("a selected value becomming invalid should no more impact the view", async function (assert) {
|
||||
assert.expect(16);
|
||||
|
||||
const kanban = await createView({
|
||||
View: KanbanView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
mockRPC: function (route, args) {
|
||||
assert.step(args.method || route);
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
services: this.services,
|
||||
arch: `
|
||||
<kanban>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="foo"/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>`,
|
||||
archs: {
|
||||
'partner,false,search': `
|
||||
<search>
|
||||
<filter name="filter_on_def" string="DEF" domain="[('state', '=', 'def')]"/>
|
||||
<searchpanel>
|
||||
<field name="state" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>`,
|
||||
},
|
||||
});
|
||||
|
||||
assert.verifySteps([
|
||||
'search_panel_select_range',
|
||||
'/web/dataset/search_read',
|
||||
]);
|
||||
|
||||
await assert.containsN(kanban, '.o_kanban_record span', 4);
|
||||
|
||||
// select 'ABC' in search panel
|
||||
await testUtils.dom.click(kanban.$('.o_search_panel_category_value:nth(1) header'));
|
||||
|
||||
assert.verifySteps([
|
||||
'search_panel_select_range',
|
||||
'/web/dataset/search_read',
|
||||
]);
|
||||
|
||||
assert.containsOnce(kanban, '.o_kanban_record span');
|
||||
assert.strictEqual(kanban.el.querySelector('.o_kanban_record span').innerText, 'yop' );
|
||||
|
||||
// select DEF in filter menu
|
||||
await testUtils.controlPanel.toggleFilterMenu(kanban);
|
||||
await testUtils.controlPanel.toggleMenuItem(kanban, 'DEF');
|
||||
|
||||
assert.verifySteps([
|
||||
'search_panel_select_range',
|
||||
'/web/dataset/search_read',
|
||||
]);
|
||||
|
||||
const firstCategoryValue = kanban.el.querySelector('.o_search_panel_category_value header');
|
||||
assert.strictEqual(firstCategoryValue.innerText, 'All');
|
||||
assert.hasClass(
|
||||
firstCategoryValue, 'active',
|
||||
"the value 'All' should be selected since ABC is no longer a valid value with respect to search domain"
|
||||
);
|
||||
assert.containsOnce(kanban, '.o_kanban_record span');
|
||||
assert.strictEqual(kanban.el.querySelector('.o_kanban_record span').innerText, 'blip' );
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user