summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2019-03-05 13:55:11 +0000
committerMartin Geubelle <mge@odoo.com>2019-03-06 10:28:01 +0000
commit1793d6d1383d17fa52f0739309e595bfdf5a278e (patch)
tree5ad91bc5c623f411fd7f4bf1bc6a9a3b4ed9f15d /addons/web/static
parent5805c032a4c8d388df2909715aac5eef8f464944 (diff)
[FIX] web: update breadcrumbs when switching view
To reproduce: 1. go on list view 2. open record in form view 3. come back on list view 4. switch to kanban 5. open record in form view 6. click on breadcrumb Before this rev. we were back on the list view, and not the kanban view. This is due to the fact that the breadcrumb was not updated when switching view, (if a controller was already existing) so the form view control panel breadcrumb was still referencing the wrong (list) controller. This bug appeared with the control panel refactoring, which is now managed by the view itself (and not the action manager as previously). Task 1932646 closes odoo/odoo#31598 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/chrome/action_manager_act_window.js3
-rw-r--r--addons/web/static/src/js/views/abstract_controller.js7
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js18
3 files changed, 25 insertions, 3 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 106f9f2aa47..d36ec9371de 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
@@ -535,6 +535,9 @@ ActionManager.include({
return newController(controller.jsID);
} else {
return $.when(controller.widget.willRestore()).then(function () {
+ viewOptions = _.extend({}, viewOptions, {
+ breadcrumbs: self._getBreadcrumbs(self.controllerStack.slice(0, index)),
+ });
return controller.widget.reload(viewOptions).then(function () {
return controller;
});
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js
index 77584a272d6..ae23d196cf9 100644
--- a/addons/web/static/src/js/views/abstract_controller.js
+++ b/addons/web/static/src/js/views/abstract_controller.js
@@ -243,7 +243,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
return;
}
self.renderer.setLocalState(localState);
- return self._update(state);
+ return self._update(state, params);
});
});
},
@@ -399,12 +399,15 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
*
* @private
* @param {Object} state the state given by the model
+ * @param {Object} [params]
+ * @param {Object[]} [params.breadcrumbs]
* @returns {Deferred}
*/
- _update: function () {
+ _update: function (state, params) {
// AAB: update the control panel -> this will be moved elsewhere at some point
var cpContent = _.extend({}, this.controlPanelElements);
this.updateControlPanel({
+ breadcrumbs: params && params.breadcrumbs,
cp_content: cpContent,
title: this.getTitle(),
});
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index 4b8a3a79751..a3501f71722 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -2276,7 +2276,7 @@ QUnit.module('ActionManager', {
});
QUnit.test('breadcrumbs are updated when switching between views', function (assert) {
- assert.expect(10);
+ assert.expect(15);
var actionManager = createActionManager({
actions: this.actions,
@@ -2297,6 +2297,20 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners',
"breadcrumbs should still display the display_name of the action");
+ // open a record in form view
+ testUtils.dom.click(actionManager.$('.o_kanban_view .o_kanban_record:first'));
+ assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
+ "there should be two controllers in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
+ "breadcrumbs should contain the display_name of the opened record");
+
+ // go back to kanban view using the breadcrumbs
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
+ assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
+ "there should be one controller in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners',
+ "breadcrumbs should display the display_name of the action");
+
// switch back to list view
testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
@@ -2313,6 +2327,8 @@ QUnit.module('ActionManager', {
// go back to list view using the breadcrumbs
testUtils.dom.click($('.o_control_panel .breadcrumb a'));
+ assert.containsOnce(actionManager, '.o_list_view',
+ "should be back on list view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should be one controller in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners',