[RFR] mis_template_financial_report: make horizontal rendering optional

This commit is contained in:
Stefan Rijnhart
2021-10-19 10:50:51 +02:00
committed by Geraldo Lopez
parent 458475146d
commit eb46d97851
9 changed files with 160 additions and 27 deletions

View File

@@ -3,14 +3,28 @@
import copy
from collections import OrderedDict
from odoo import models
from odoo import api, fields, models
class MisReportInstance(models.Model):
_inherit = "mis.report.instance"
allow_horizontal = fields.Boolean(compute="_compute_allow_horizontal")
horizontal = fields.Boolean()
@api.depends("report_id")
def _compute_allow_horizontal(self):
"""Indicate that the instance supports horizontal rendering."""
for instance in self:
instance.allow_horizontal = set(
instance.report_id.get_external_id().values()
) & {
"mis_template_financial_report.report_bs",
"mis_template_financial_report.report_pl",
}
def compute(self):
if not self._is_horizontal():
if not self.horizontal:
return super().compute()
full_matrix = self._compute_matrix()
@@ -24,14 +38,6 @@ class MisReportInstance(models.Model):
return result
def _is_horizontal(self):
"""Determine if the report template is a horizontal one"""
self.ensure_one()
return set(self.report_id.get_external_id().values()) & {
"mis_template_financial_report.report_bs",
"mis_template_financial_report.report_pl",
}
def _compute_horizontal_matrices(self, matrix=None):
"""Compute the matrix (if not passed) and return the split versions"""
return self._split_matrix(