[IMP] web: allow linking to another model on graph and pivot views
This commit makes it simpler to override the action executed when clicking on pivot cells or graph bars. This is a nice to have for reports where we don't want to open the report model but the model the report is based on. TaskId-2764844 Part-of: odoo/odoo#85404
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user