summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2018-09-27 11:43:29 +0200
committerMartin Geubelle <mge@odoo.com>2018-09-27 12:34:04 +0200
commitf4b2060af51f8e1d896711be55f7bee8c6d1bb75 (patch)
treed72cfe9ff483418de56f673f070500f195ba9916
parentcf50388d1016908e537231a78adb041af897aabb (diff)
[FIX] web: handle lazy load with previous actions
Before this rev. the lazy loading of views was correctly handled if there was only one action in the action stack (which is usually the case when performing a F5, the main use case of the view lazy loading). Nevertheless, it might happen that the lazy-loading is used in top of other actions (when performing a `doAction` with a form view for an action with another view as first view, i.e. when leaving Studio while editing the form view). The controller was `unshift` in the case (put in the first position of the controller stack), which is not correct. This causes the breadcrumb to be misordered and a traceback occured when trying to access a breadcrumb element. Co-authored-by: Aaron Bohy <aab@odoo.com>
-rw-r--r--addons/web/static/src/js/chrome/action_manager_act_window.js4
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js37
2 files changed, 40 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js
index eee8ffc9e92..c41123828f4 100644
--- a/addons/web/static/src/js/chrome/action_manager_act_window.js
+++ b/addons/web/static/src/js/chrome/action_manager_act_window.js
@@ -340,7 +340,9 @@ ActionManager.include({
action.controllerID = controller.jsID;
return self._executeAction(action, options).done(function () {
if (lazyLoadedController) {
- self.controllerStack.unshift(lazyLoadedController.jsID);
+ // controller should be placed just before the current one
+ var index = self.controllerStack.length - 1;
+ self.controllerStack.splice(index, 0, lazyLoadedController.jsID);
self.controlPanel.update({
breadcrumbs: self._getBreadcrumbs(),
}, {clear: false});
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index 82bf9f5c3d3..ee95b8ac530 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -804,6 +804,43 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
+ QUnit.test('lazy load multi record view with previous action', function (assert) {
+ assert.expect(6);
+
+ var actionManager = createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ debug: 1,
+ });
+ actionManager.doAction(4);
+
+ assert.strictEqual($('.o_control_panel .breadcrumb li').length, 1,
+ "there should be one controller in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb li').text(), 'Partners Action 4',
+ "breadcrumbs should contain the display_name of the opened record");
+
+ actionManager.doAction(3, {
+ resID: 2,
+ viewType: 'form',
+ });
+
+ assert.strictEqual($('.o_control_panel .breadcrumb li').length, 3,
+ "there should be three controllers in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb li').text(), 'Partners Action 4PartnersSecond record',
+ "the breadcrumb elements should be correctly ordered");
+
+ // go back to List
+ $('.o_control_panel .breadcrumb a:last').click();
+
+ assert.strictEqual($('.o_control_panel .breadcrumb li').length, 2,
+ "there should be two controllers in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb li').text(), 'Partners Action 4Partners',
+ "the breadcrumb elements should be correctly ordered");
+
+ actionManager.destroy();
+ });
+
QUnit.test('change the viewType of the current action', function (assert) {
assert.expect(13);