Skip to content

Commit

Permalink
[IMP] mis_builder: provide more views in drilldown
Browse files Browse the repository at this point in the history
Prior to this commit only the `tree` and `form` views where made available
while drilldowning in the `mis.report.instance` preview.

After this commit if available, the `tree`, `form`, `pivot` and `chart` views
will be provided.

The available views and orders can be easilly overriden.
  • Loading branch information
Laurent Stukkens committed Nov 16, 2023
1 parent 0ff1cde commit fee954f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions mis_builder/models/mis_report_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,21 @@ def compute(self):
kpi_matrix = self._compute_matrix()
return kpi_matrix.as_dict()

@api.model
def _get_drilldown_views_and_orders(self):
return {"tree": 1, "form": 2, "pivot": 3, "graph": 4}

def _get_drilldown_model_views(self):
self.ensure_one()
types = self.env["ir.ui.view"]._read_group(
[("model", "=", self.source_aml_model_name)], ["type"], ["type"]
)
views_order = self._get_drilldown_views_and_orders()
views = {type["type"] for type in types if type["type"] in views_order}
if "tree" in views and "form" not in views:
views.add("form")
return sorted(list(views), key=lambda x: views_order[x])

def drilldown(self, arg):
self.ensure_one()
period_id = arg.get("period_id")
Expand All @@ -896,13 +911,14 @@ def drilldown(self, arg):
account_id,
)
domain.extend(period._get_additional_move_line_filter())
views = self._get_drilldown_model_views()
return {
"name": self._get_drilldown_action_name(arg),
"domain": domain,
"type": "ir.actions.act_window",
"res_model": period.source_aml_model_name,
"views": [[False, "list"], [False, "form"]],
"view_mode": "list",
"views": [[False, view] for view in views],
"view_mode": ",".join(view for view in views),
"target": "current",
"context": {"active_test": False},
}
Expand Down

0 comments on commit fee954f

Please sign in to comment.