From 017e71322b6b7f0c232f0d66ba659a5972fc3534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 3 Sep 2018 15:01:46 +0200 Subject: [PATCH] [FIX] web: display view name in debug menu ('Edit View: X') Revision on https://github.com/odoo/odoo/commit/f7fbe8adffb1ee585c8171f6c86d38145c11848d The commit above wrongly assumes that the object 'view' is an instance of the view class. As a result, the property `display_name` was undefined. This commit fixes the issue by letting the controller remember the name of the view in a similar was as the type of the view. That way, the name of the view can simply be retrieved from the instance of the controller class. Task-ID 1878254 --- addons/web/static/src/js/views/abstract_controller.js | 3 +++ addons/web/static/src/js/views/abstract_view.js | 1 + addons/web/static/src/xml/base.xml | 2 +- addons/web/static/tests/tools/debug_manager_tests.js | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 4bcb21f7a4d..c5fa0ff6eed 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -43,6 +43,8 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, { * @param {any} params.initialState the initialState * @param {boolean} params.isMultiRecord * @param {Object[]} params.actionViews + * @param {string|Object} params.viewName name of the view (e.g "List"). + * This is an object with `core._lt`. * @param {string} params.viewType * @param {boolean} params.withControlPanel set to false to hide the * ControlPanel @@ -69,6 +71,7 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, { this.groupable = params.groupable; this.enableTimeRangeMenu = params.enableTimeRangeMenu; this.actionViews = params.actionViews; + this.viewName = params.viewName; this.viewType = params.viewType; this.withControlPanel = params.withControlPanel !== false; // override this.need_control_panel so that the ActionManager doesn't diff --git a/addons/web/static/src/js/views/abstract_view.js b/addons/web/static/src/js/views/abstract_view.js index d061349b7c8..f090d5d4e84 100644 --- a/addons/web/static/src/js/views/abstract_view.js +++ b/addons/web/static/src/js/views/abstract_view.js @@ -153,6 +153,7 @@ var AbstractView = Class.extend({ this.controllerParams.searchView = params.action && params.action.searchView; this.controllerParams.searchViewHidden = this.searchview_hidden; // AAB: use searchable instead where it is used? this.controllerParams.actionViews = params.action ? params.action.views : []; + this.controllerParams.viewName = this.viewName; this.controllerParams.viewType = this.viewType; this.controllerParams.withControlPanel = true; if (params.action && params.action.flags) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index e4a77c274b3..decf5eb98af 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -272,7 +272,7 @@ Fields View Get - Edit View: + Edit View: Edit SearchView diff --git a/addons/web/static/tests/tools/debug_manager_tests.js b/addons/web/static/tests/tools/debug_manager_tests.js index 27498400b2a..e861afc6546 100644 --- a/addons/web/static/tests/tools/debug_manager_tests.js +++ b/addons/web/static/tests/tools/debug_manager_tests.js @@ -52,10 +52,10 @@ QUnit.module('DebugManager', {}, function () { view_id: 1, }, type: "list", - display_name: "List", }], }; var view = { + viewName: "List", viewType: "list", }; debugManager.update('action', action, view);