diff --git a/addons/web/static/src/views/graph/graph_view.js b/addons/web/static/src/views/graph/graph_view.js index 5faa5d8da01..7e75d0b2553 100644 --- a/addons/web/static/src/views/graph/graph_view.js +++ b/addons/web/static/src/views/graph/graph_view.js @@ -67,11 +67,34 @@ export class GraphView extends Component { }; } + /** + * Execute the action to open the view on the current model. + * + * @param {Array} domain + * @param {Array} views + * @param {Object} context + */ + openView(domain, views, context) { + this.actionService.doAction( + { + context, + domain, + name: this.model.metaData.title, + res_model: this.model.metaData.resModel, + target: "current", + type: "ir.actions.act_window", + views: views, + }, + { + viewType: "list", + } + ); + } /** * @param {string} domain the domain of the clicked area */ onGraphClicked(domain) { - const { context, resModel, title } = this.model.metaData; + const { context } = this.model.metaData; Object.keys(context).forEach((x) => { if (x === "group_by" || x.startsWith("search_default_")) { @@ -87,21 +110,7 @@ export class GraphView extends Component { return [views[viewType] || false, viewType]; } const actionViews = [getView("list"), getView("form")]; - - this.actionService.doAction( - { - context, - domain, - name: title, - res_model: resModel, - target: "current", - type: "ir.actions.act_window", - views: actionViews, - }, - { - viewType: "list", - } - ); + this.openView(domain, actionViews, context); } /** diff --git a/addons/web/static/src/views/pivot/pivot_view.js b/addons/web/static/src/views/pivot/pivot_view.js index 585f23efa95..a039dfa0772 100644 --- a/addons/web/static/src/views/pivot/pivot_view.js +++ b/addons/web/static/src/views/pivot/pivot_view.js @@ -115,6 +115,25 @@ export class PivotView extends Component { onMeasureSelected({ measure }) { this.model.toggleMeasure(measure); } + /** + * Execute the action to open the view on the current model. + * + * @param {Array} domain + * @param {Array} views + * @param {Object} context + */ + openView(domain, views, context) { + this.actionService.doAction({ + type: "ir.actions.act_window", + name: this.model.metaData.title, + res_model: this.props.resModel, + views: views, + view_mode: "list", + target: "current", + context, + domain, + }); + } /** * @param {CustomEvent} ev */ @@ -142,18 +161,7 @@ export class PivotView extends Component { colValues: cell.groupId[1], originIndex: cell.originIndexes[0], }; - const domain = this.model.getGroupDomain(group); - - this.actionService.doAction({ - type: "ir.actions.act_window", - name: this.model.metaData.title, - res_model: this.props.resModel, - views: this.views, - view_mode: "list", - target: "current", - context, - domain, - }); + this.openView(this.model.getGroupDomain(group), this.views, context); } }