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_view.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_view.js')
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_view.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_view.js b/addons/web/static/src/js/views/graph/graph_view.js index 488424536e6..5ae120343c6 100644 --- a/addons/web/static/src/js/views/graph/graph_view.js +++ b/addons/web/static/src/js/views/graph/graph_view.js @@ -115,8 +115,23 @@ var GraphView = AbstractView.extend({ this.controllerParams.withButtons = params.withButtons !== false; this.controllerParams.measures = [...sortedMeasures, countMeasure]; this.controllerParams.groupableFields = groupableFields; + this.controllerParams.title = params.title || this.arch.attrs.string || _t("Untitled"); + // retrieve form and list view ids from the action to open those views + // when the graph is clicked + function _findView(views, viewType) { + const view = views.find(view => { + return view.type === viewType; + }); + return [view ? view.viewID : false, viewType]; + } + this.controllerParams.views = [ + _findView(params.actionViews, 'list'), + _findView(params.actionViews, 'form'), + ]; + this.rendererParams.fields = this.fields; this.rendererParams.title = this.arch.attrs.title; // TODO: use attrs.string instead + this.rendererParams.disableLinking = !!JSON.parse(this.arch.attrs.disable_linking || '0'); this.loadParams.mode = this.arch.attrs.type || 'bar'; this.loadParams.measure = measure || '__count__'; |
