[FIX] base: can execute action from settings

Before this commit, when being in a settings form view with at
least two items in the breadcrumbs (the settings view preceeded by
another one), clicking on a button to execute an action didn't
properly work: an history back was done instead, thus returning to
the previous action.

For instance, go to Sales (without demo data), click on 'Set
payments' in the onboarding banner, click 'Go to the configuration
panel', and in the settings view click on 'Install More Packages'.

The issue has been introduced by [1], but we couldn't find a
scenario to reproduce it before saas-13.3.

[1] a3845ae3f0

Issue spotted in task 2277314

closes odoo/odoo#55351

X-original-commit: 6ccb108e9a621a672fde715ea78656ffeb6834e5
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2020-08-03 16:17:19 +00:00
parent ee623f1f26
commit 721f38b11d
2 changed files with 66 additions and 1 deletions
@@ -297,7 +297,7 @@ var BaseSettingController = FormController.extend({
var recordID = ev.data.recordID;
var _super = this._super;
var args = arguments;
this._discardChanges(recordID).then(function () {
this._discardChanges(recordID, { noAbandon: true }).then(function () {
_super.apply(self, args);
});
} else {
@@ -359,5 +359,70 @@ QUnit.module('base_settings_tests', {
form.destroy();
});
QUnit.test('execute action from settings view with several actions in the breadcrumb', async function (assert) {
// This commit fixes a race condition, that's why we artificially slow down a read rpc
assert.expect(4);
const actions = [{
id: 1,
name: 'First action',
res_model: 'project',
type: 'ir.actions.act_window',
views: [[1, 'list']],
}, {
id: 2,
name: 'Settings view',
res_model: 'project',
type: 'ir.actions.act_window',
views: [[2, 'form']],
}, {
id: 3,
name: 'Other action',
res_model: 'project',
type: 'ir.actions.act_window',
views: [[3, 'list']],
}];
const archs = {
'project,1,list': '<tree><field name="foo"/></tree>',
'project,2,form': `
<form string="Settings" js_class="base_settings">
<div class="app_settings_block" string="CRM" data-key="crm">
<button name="3" string="Execute action" type="action"/>
</div>
</form>`,
'project,3,list': '<tree><field name="foo"/></tree>',
'project,false,search': '<search></search>',
};
let loadViewsDef;
const actionManager = await createActionManager({
actions: actions,
archs: archs,
data: this.data,
async mockRPC(route, args) {
const _super = this._super.bind(this);
if (args.method === 'read') {
await Promise.resolve(loadViewsDef); // slow down reload of settings view
}
return _super(route, args);
},
});
await actionManager.doAction(1);
assert.strictEqual(actionManager.$('.breadcrumb').text(), 'First action');
await actionManager.doAction(2);
assert.strictEqual(actionManager.$('.breadcrumb').text(), 'First actionNew');
loadViewsDef = testUtils.makeTestPromise();
await testUtils.dom.click(actionManager.$('button[name="3"]'));
assert.strictEqual(actionManager.$('.breadcrumb').text(), 'First actionNew');
loadViewsDef.resolve();
await testUtils.nextTick();
assert.strictEqual(actionManager.$('.breadcrumb').text(), 'First actionNewOther action');
actionManager.destroy();
});
});
});