diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 114009a784616..b54e5e0afb3f7 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -282,6 +282,10 @@ def generate_views(action): # providing at least one view mode is a requirement, not an option view_modes = action['view_mode'].split(',') + # BLUE STINGRAY / METRIC WISE CUSTOM + # make sure the view_description is instantiated + view_description = action['view_description'] or False + if len(view_modes) > 1: if view_id: raise ValueError('Non-db action dictionaries should provide ' @@ -291,7 +295,7 @@ def generate_views(action): view_modes, view_id, action)) action['views'] = [(False, mode) for mode in view_modes] return - action['views'] = [(view_id, view_modes[0])] + action['views'] = [(view_id, view_modes[0], view_description)] def fix_view_modes(action): """ For historical reasons, Odoo has weird dealings in relation to diff --git a/addons/web/static/src/legacy/js/chrome/abstract_action.js b/addons/web/static/src/legacy/js/chrome/abstract_action.js index 53c15c43d95c3..fd539ac0e47ca 100644 --- a/addons/web/static/src/legacy/js/chrome/abstract_action.js +++ b/addons/web/static/src/legacy/js/chrome/abstract_action.js @@ -50,6 +50,17 @@ const AbstractAction = Widget.extend(ActionMixin, { */ withSearchBar: false, + /** + * BLUE STINGRAY / METRIC WISE CUSTOM + * A client action might want to see the view description displayed in its + * control panel, or it choose not to use it. + * + * It also only makes sense if hasControlPanel is set to true. + * + * @type boolean + */ + withViewDescription: false, + /** * This parameter can be set to customize the available sub menus in the * controlpanel (Filters/Group By/Favorites). This is basically a list of @@ -74,6 +85,7 @@ const AbstractAction = Widget.extend(ActionMixin, { init: function (parent, action, options) { this._super(parent); this._title = action.display_name || action.name; + this._viewDescription = action.view_description; this.searchModelConfig = { context: Object.assign({}, action.context), @@ -86,6 +98,7 @@ const AbstractAction = Widget.extend(ActionMixin, { this.extensions.ControlPanel = { actionId: action.id, withSearchBar: this.withSearchBar, + withViewDescription: this.withViewDescription, }; this.viewId = action.search_view_id && action.search_view_id[0]; @@ -95,6 +108,7 @@ const AbstractAction = Widget.extend(ActionMixin, { breadcrumbs: options && options.breadcrumbs, withSearchBar: this.withSearchBar, searchMenuTypes: this.searchMenuTypes, + withViewDescription: this.withViewDescription, }; } }, diff --git a/addons/web/static/src/legacy/js/chrome/action_mixin.js b/addons/web/static/src/legacy/js/chrome/action_mixin.js index 82feba041026f..9a121d66a9d70 100644 --- a/addons/web/static/src/legacy/js/chrome/action_mixin.js +++ b/addons/web/static/src/legacy/js/chrome/action_mixin.js @@ -65,6 +65,14 @@ odoo.define('web.ActionMixin', function (require) { */ _title: '', + /** + * BLUE STINGRAY / METRIC WISE CUSTOM + * String containing the view description of the client action + * + * @see _setViewDescription + */ + _viewDescription: '', + /** * @override */ @@ -154,6 +162,17 @@ odoo.define('web.ActionMixin', function (require) { return this._title; }, + /** + * BLUE STINGRAY / METRIC WISE CUSTOM + * Returns a view_description that may be displayed in center of the + * control panel area. + * + * @returns {string} + */ + getViewDescription: function () { + return this._viewDescription; + }, + /** * Renders the buttons to append, in most cases, to the control panel (in * the bottom left corner). When the action is rendered in a dialog, those @@ -187,6 +206,11 @@ odoo.define('web.ActionMixin', function (require) { this.controlPanelProps.title = this.getTitle(); delete props.title; } + if ('view_description' in props) { + this._setViewDescription(props.view_description); + this.controlPanelProps.view_description = this.getViewDescription(); + delete props.view_description; + } if ('cp_content' in props) { // cp_content has been updated: refresh it. this.controlPanelProps.cp_content = Object.assign({}, @@ -212,6 +236,14 @@ odoo.define('web.ActionMixin', function (require) { this._title = title; }, + /** + * @private + * @param {string} view_description + */ + _setViewDescription: function (view_description) { + this._viewDescription = view_description; + }, + //--------------------------------------------------------------------- // Handlers //--------------------------------------------------------------------- diff --git a/addons/web/static/src/legacy/js/control_panel/control_panel.js b/addons/web/static/src/legacy/js/control_panel/control_panel.js index 638dbce8f0324..ee4790f283c67 100644 --- a/addons/web/static/src/legacy/js/control_panel/control_panel.js +++ b/addons/web/static/src/legacy/js/control_panel/control_panel.js @@ -212,6 +212,7 @@ odoo.define('web.ControlPanel', function (require) { actionMenus: { validate: s => typeof s === 'object' || s === null, optional: 1 }, title: { type: String, optional: 1 }, view: { type: Object, optional: 1 }, + view_description: { type: String, optional: 1 }, views: Array, withBreadcrumbs: Boolean, withSearchBar: Boolean, diff --git a/addons/web/static/src/legacy/js/views/abstract_view.js b/addons/web/static/src/legacy/js/views/abstract_view.js index fba546b0c08c6..8bad99a874291 100644 --- a/addons/web/static/src/legacy/js/views/abstract_view.js +++ b/addons/web/static/src/legacy/js/views/abstract_view.js @@ -256,6 +256,7 @@ var AbstractView = Factory.extend({ fields, searchMenuTypes: params.searchMenuTypes, view: this.fieldsView, + view_description: params.action.view_description || "", views: params.action.views && params.action.views.filter( v => v.multiRecord === this.multi_record ), diff --git a/addons/web/static/src/legacy/xml/base.xml b/addons/web/static/src/legacy/xml/base.xml index bb30b5fe5b72c..b806ac752ada1 100644 --- a/addons/web/static/src/legacy/xml/base.xml +++ b/addons/web/static/src/legacy/xml/base.xml @@ -24,6 +24,13 @@ +