diff options
| author | Dhruv Patel <dhp@odoo.com> | 2020-03-16 04:55:53 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-03-31 19:15:10 +0000 |
| commit | ae610d0e205da921111b5a320dec833d84b05056 (patch) | |
| tree | cee9944daad0d58986d75823ac5562768d1f264d /addons/web/static/src/js/views/graph/graph_controller.js | |
| parent | 2516c0a212a7181fb8f54ce1bd5b46b30ffd8edf (diff) | |
[IMP] web: graph: drill down to records in bar/pie charts
After this commit, in the graph view, when the user clicks on parts
of the bar and pie charts, it opens the list view of the concerned
records (like what was already done in the pivot view).
This is the default behavior, but it can be deactivated by setting
the attribute 'disable_linking' to true in the view.
Task 2198461
closes odoo/odoo#47796
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/graph/graph_controller.js')
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_controller.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_controller.js b/addons/web/static/src/js/views/graph/graph_controller.js index f47bfaeb5bb..eb5fd107081 100644 --- a/addons/web/static/src/js/views/graph/graph_controller.js +++ b/addons/web/static/src/js/views/graph/graph_controller.js @@ -23,6 +23,7 @@ class CarretDropdownMenu extends DropdownMenu { var GraphController = AbstractController.extend({ custom_events: _.extend({}, AbstractController.prototype.custom_events, { item_selected: '_onItemSelected', + open_view: '_onOpenView', }), /** @@ -42,6 +43,9 @@ var GraphController = AbstractController.extend({ // button in the control panel owned by the graph view. this.isEmbedded = params.isEmbedded; this.withButtons = params.withButtons; + // views to use in the action triggered when the graph is clicked + this.views = params.views; + this.title = params.title; // this parameter determines what is the list of fields // that may be used within the groupby menu available when @@ -296,6 +300,32 @@ var GraphController = AbstractController.extend({ this.measureMenu.update({ items: this.measures }); } }, + + /** + * @private + * @param {OdooEvent} ev + * @param {Array[]} ev.data.domain + */ + _onOpenView(ev) { + ev.stopPropagation(); + const state = this.model.get(); + const context = Object.assign({}, state.context); + Object.keys(context).forEach(x => { + if (x === 'group_by' || x.startsWith('search_default_')) { + delete context[x]; + } + }); + this.do_action({ + context: context, + domain: ev.data.domain, + name: this.title, + res_model: this.modelName, + target: 'current', + type: 'ir.actions.act_window', + view_mode: 'list', + views: this.views, + }); + }, }); return GraphController; |
