[FIX] mis_template_financial_report: feature parity with v12
parent
a055578804
commit
9066e2df2d
|
@ -7,7 +7,7 @@ Profit & Loss / Balance sheet MIS templates
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:ced5b0160af86207e009f52aac7844010df11f150873af1601845c0f0958ec23
|
!! source digest: sha256:35e3ad836c47238b09fe511febcb806bafddc4699aedb0e224e55517c31128d0
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||||
|
@ -53,6 +53,7 @@ Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
|
||||||
* support horizontal mode for xslx export
|
* support horizontal mode for xslx export
|
||||||
|
* split off all code to `mis_builder_horizontal` and only keep the KPI definitions here
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
@ -15,16 +15,17 @@
|
||||||
"data/mis_report_kpi.xml",
|
"data/mis_report_kpi.xml",
|
||||||
"data/mis_report_subreport.xml",
|
"data/mis_report_subreport.xml",
|
||||||
"views/mis_report_instance_views.xml",
|
"views/mis_report_instance_views.xml",
|
||||||
|
"views/mis_report_kpi_views.xml",
|
||||||
"views/templates.xml",
|
"views/templates.xml",
|
||||||
],
|
],
|
||||||
"assets": {
|
"assets": {
|
||||||
"web.assets_backend": [
|
"web.assets_backend": [
|
||||||
"mis_template_financial_report/static/src/css/mis_template_financial_report.css",
|
"mis_template_financial_report/static/src/components/mis_report_widget.xml",
|
||||||
|
"mis_template_financial_report/static/src/components/mis_report_widget.css",
|
||||||
],
|
],
|
||||||
"web.report_assets_common": [
|
"web.report_assets_common": [
|
||||||
"mis_template_financial_report/static/src/css/report.css"
|
"mis_template_financial_report/static/src/css/report.css"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"qweb": ["static/src/xml/mis_template_financial_report.xml"],
|
|
||||||
"maintainers": ["hbrunn"],
|
"maintainers": ["hbrunn"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<field name="accumulation_method">sum</field>
|
<field name="accumulation_method">sum</field>
|
||||||
<field name="sequence">0</field>
|
<field name="sequence">0</field>
|
||||||
<field name="report_id" ref="report_pl" />
|
<field name="report_id" ref="report_pl" />
|
||||||
|
<field name="split_after" eval="True" />
|
||||||
</record>
|
</record>
|
||||||
<record id="kpi_pl_to_report" model="mis.report.kpi">
|
<record id="kpi_pl_to_report" model="mis.report.kpi">
|
||||||
<field name="id">3</field>
|
<field name="id">3</field>
|
||||||
|
@ -93,5 +94,6 @@
|
||||||
<field name="accumulation_method">sum</field>
|
<field name="accumulation_method">sum</field>
|
||||||
<field name="sequence">0</field>
|
<field name="sequence">0</field>
|
||||||
<field name="report_id" ref="report_bs" />
|
<field name="report_id" ref="report_bs" />
|
||||||
|
<field name="split_after" eval="True" />
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
from . import mis_report_instance
|
from . import mis_report_instance
|
||||||
|
from . import mis_report_kpi
|
||||||
|
|
|
@ -16,12 +16,9 @@ class MisReportInstance(models.Model):
|
||||||
def _compute_allow_horizontal(self):
|
def _compute_allow_horizontal(self):
|
||||||
"""Indicate that the instance supports horizontal rendering."""
|
"""Indicate that the instance supports horizontal rendering."""
|
||||||
for instance in self:
|
for instance in self:
|
||||||
instance.allow_horizontal = set(
|
instance.allow_horizontal = any(
|
||||||
instance.report_id.get_external_id().values()
|
instance.mapped("report_id.kpi_ids.split_after")
|
||||||
) & {
|
)
|
||||||
"mis_template_financial_report.report_bs",
|
|
||||||
"mis_template_financial_report.report_pl",
|
|
||||||
}
|
|
||||||
|
|
||||||
def compute(self):
|
def compute(self):
|
||||||
if not self.horizontal:
|
if not self.horizontal:
|
||||||
|
@ -29,55 +26,28 @@ class MisReportInstance(models.Model):
|
||||||
|
|
||||||
full_matrix = self._compute_matrix()
|
full_matrix = self._compute_matrix()
|
||||||
|
|
||||||
matrices = self._compute_horizontal_matrices(full_matrix)
|
matrices = self._split_matrix(full_matrix)
|
||||||
|
|
||||||
result = full_matrix.as_dict()
|
result = full_matrix.as_dict()
|
||||||
result["horizontal_matrices"] = [
|
result["split_matrices"] = [extra_matrix.as_dict() for extra_matrix in matrices]
|
||||||
extra_matrix.as_dict() for extra_matrix in matrices
|
|
||||||
]
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _compute_horizontal_matrices(self, matrix=None):
|
def _split_matrix(self, original_matrix):
|
||||||
"""Compute the matrix (if not passed) and return the split versions"""
|
"""Split a matrix according to the split_after flag in the kpis used"""
|
||||||
return self._split_matrix(
|
|
||||||
matrix or self._compute_matrix(),
|
|
||||||
[
|
|
||||||
(
|
|
||||||
self.env.ref("mis_template_financial_report.kpi_profit"),
|
|
||||||
self.env.ref("mis_template_financial_report.kpi_pl_to_report"),
|
|
||||||
self.env.ref("mis_template_financial_report.kpi_assets"),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
def _split_matrix(self, original_matrix, kpi_defs=None, keep_remaining=True):
|
|
||||||
"""Split a matrix by duplicating it as shallowly as possible and removing
|
|
||||||
rows according to kpi_defs
|
|
||||||
|
|
||||||
KPIs not listed there will end up together in the last matrix if
|
|
||||||
`keep_remaining` is set.
|
|
||||||
|
|
||||||
:param kpi_defs: [(kpi_first_matrix1, ...), (kpi_second_matrix1, ...)]
|
|
||||||
:return: list of KpiMatrix
|
|
||||||
"""
|
|
||||||
result = []
|
result = []
|
||||||
remaining_rows = original_matrix._kpi_rows.copy()
|
|
||||||
|
|
||||||
for kpis in kpi_defs:
|
def clone_matrix():
|
||||||
matrix = copy.copy(original_matrix)
|
clone = copy.copy(original_matrix)
|
||||||
matrix._kpi_rows = OrderedDict(
|
clone._kpi_rows = OrderedDict()
|
||||||
[
|
result.append(clone)
|
||||||
(kpi, remaining_rows.pop(kpi))
|
return clone
|
||||||
for kpi in kpis
|
|
||||||
if kpi in remaining_rows
|
|
||||||
]
|
|
||||||
)
|
|
||||||
result.append(matrix)
|
|
||||||
|
|
||||||
if remaining_rows and keep_remaining:
|
current = clone_matrix()
|
||||||
matrix = copy.copy(original_matrix)
|
|
||||||
matrix._kpi_rows = remaining_rows
|
for kpi in original_matrix._kpi_rows:
|
||||||
result.append(matrix)
|
current._kpi_rows[kpi] = original_matrix._kpi_rows[kpi]
|
||||||
|
if kpi.split_after:
|
||||||
|
current = clone_matrix()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Copyright 2023 Hunki Enterprises BV
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class MisReportKpi(models.Model):
|
||||||
|
_inherit = "mis.report.kpi"
|
||||||
|
|
||||||
|
split_after = fields.Boolean(
|
||||||
|
help="Split the table after this KPI. This allows displaying KPIs next to each "
|
||||||
|
"other in non-comparison mode",
|
||||||
|
)
|
|
@ -1 +1,2 @@
|
||||||
* support horizontal mode for xslx export
|
* support horizontal mode for xslx export
|
||||||
|
* split off all code to `mis_builder_horizontal` and only keep the KPI definitions here
|
||||||
|
|
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:ced5b0160af86207e009f52aac7844010df11f150873af1601845c0f0958ec23
|
!! source digest: sha256:35e3ad836c47238b09fe511febcb806bafddc4699aedb0e224e55517c31128d0
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-reporting/tree/16.0/mis_template_financial_report"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-reporting-16-0/account-financial-reporting-16-0-mis_template_financial_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-reporting/tree/16.0/mis_template_financial_report"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-reporting-16-0/account-financial-reporting-16-0-mis_template_financial_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-reporting&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This addon provides MIS builder templates to generate generic Profit & Loss and Balance Sheet reports.</p>
|
<p>This addon provides MIS builder templates to generate generic Profit & Loss and Balance Sheet reports.</p>
|
||||||
|
@ -401,6 +401,7 @@ This checkbox is only available for reports that support the horizontal mode.</p
|
||||||
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>support horizontal mode for xslx export</li>
|
<li>support horizontal mode for xslx export</li>
|
||||||
|
<li>split off all code to <cite>mis_builder_horizontal</cite> and only keep the KPI definitions here</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
.oe_mis_builder_content.horizontal {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
.oe_mis_builder_content.horizontal .oe_mis_builder_cp {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.oe_mis_builder_content.horizontal .o_list_renderer {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<templates>
|
||||||
|
|
||||||
|
<t t-inherit="mis_builder.MisReportWidget" t-inherit-mode="extension">
|
||||||
|
<xpath expr="//div[hasclass('oe_mis_builder_content')]" position="attributes">
|
||||||
|
<attribute
|
||||||
|
name="t-attf-class"
|
||||||
|
>{{state.mis_report_data.split_matrices and 'horizontal'}}</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//table[hasclass('mis_builder')]/.." position="attributes">
|
||||||
|
<attribute
|
||||||
|
name="t-foreach"
|
||||||
|
>state.mis_report_data.split_matrices or [state.mis_report_data]</attribute>
|
||||||
|
<attribute name="t-as">matrix</attribute>
|
||||||
|
<attribute name="t-key">matrix_index</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<xpath
|
||||||
|
expr="//tr[@t-foreach='state.mis_report_data.header']"
|
||||||
|
position="attributes"
|
||||||
|
>
|
||||||
|
<attribute name="t-foreach">matrix.header</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath
|
||||||
|
expr="//tr[@t-foreach='state.mis_report_data.body']"
|
||||||
|
position="attributes"
|
||||||
|
>
|
||||||
|
<attribute name="t-foreach">matrix.body</attribute>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
</templates>
|
|
@ -1,7 +0,0 @@
|
||||||
.oe_mis_builder_content div.mis_builder_horizontal {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.oe_mis_builder_content div.mis_builder_horizontal .table {
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
|
@ -1,11 +1,11 @@
|
||||||
div.mis_builder_horizontal {
|
div.mis_builder_horizontal_container {
|
||||||
display: table;
|
display: table;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
border-spacing: 5px;
|
||||||
}
|
}
|
||||||
div.mis_builder_horizontal > div {
|
div.mis_builder_horizontal_row {
|
||||||
display: table-row;
|
display: table-row;
|
||||||
}
|
}
|
||||||
div.mis_builder_horizontal > div > div {
|
div.mis_builder_horizontal_cell {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
padding: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<template>
|
|
||||||
<t t-extend="MisReportWidgetTemplate">
|
|
||||||
<t t-jquery="table.mis_builder">
|
|
||||||
var $full_table = jQuery(this);
|
|
||||||
var $wrapper = jQuery(
|
|
||||||
'<div />'
|
|
||||||
).addClass('mis_builder_horizontal').insertAfter($full_table);
|
|
||||||
var $table = $full_table.clone().appendTo($wrapper);
|
|
||||||
$table.attr({
|
|
||||||
't-foreach': 'widget.mis_report_data.horizontal_matrices || []',
|
|
||||||
't-as': 'matrix',
|
|
||||||
});
|
|
||||||
$table.find('tr[t-foreach="widget.mis_report_data.header"]').attr(
|
|
||||||
't-foreach', 'matrix.header'
|
|
||||||
);
|
|
||||||
$table.find('tr[t-foreach="widget.mis_report_data.body"]').attr(
|
|
||||||
't-foreach', 'matrix.body'
|
|
||||||
);
|
|
||||||
$full_table.attr('t-if', '!widget.mis_report_data.horizontal_matrices');
|
|
||||||
</t>
|
|
||||||
</t>
|
|
||||||
</template>
|
|
|
@ -15,4 +15,4 @@ class TestMisTemplateFinancialReport(TestMisReportInstance):
|
||||||
self.assertTrue(instance.allow_horizontal)
|
self.assertTrue(instance.allow_horizontal)
|
||||||
instance.horizontal = True
|
instance.horizontal = True
|
||||||
result_dict = instance.compute()
|
result_dict = instance.compute()
|
||||||
self.assertEqual(len(result_dict.get("horizontal_matrices", [])), 2)
|
self.assertEqual(len(result_dict.get("split_matrices", [])), 2)
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="mis_report_view_kpi_form">
|
||||||
|
<field name="model">mis.report.kpi</field>
|
||||||
|
<field name="inherit_id" ref="mis_builder.mis_report_view_kpi_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='auto_expand_accounts']/.." position="after">
|
||||||
|
<group name="split" string="Splitting">
|
||||||
|
<field name="split_after" />
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
|
@ -2,42 +2,25 @@
|
||||||
<template
|
<template
|
||||||
id="report_mis_report_instance"
|
id="report_mis_report_instance"
|
||||||
inherit_id="mis_builder.report_mis_report_instance"
|
inherit_id="mis_builder.report_mis_report_instance"
|
||||||
priority="9999"
|
|
||||||
>
|
>
|
||||||
<xpath expr="//div[hasclass('mis_table')]" position="attributes">
|
<xpath expr="//div[hasclass('mis_table')]" position="before">
|
||||||
<attribute name="t-if">not o.horizontal</attribute>
|
<div class="mis_builder_horizontal_container">
|
||||||
</xpath>
|
<div class="mis_builder_horizontal_row">
|
||||||
<!-- the following is a somewhat convoluted way to duplicate the table /-->
|
<div
|
||||||
<xpath expr="//div[hasclass('mis_table')]" position="replace">
|
class="mis_builder_horizontal_cell"
|
||||||
<t t-marker="unwrap">$0</t>
|
t-foreach="o.horizontal and o._split_matrix(matrix) or [matrix]"
|
||||||
<t t-marker="wrap_in_table">$0</t>
|
t-as="matrix"
|
||||||
</xpath>
|
|
||||||
<xpath expr="//t[@t-marker='unwrap']" position="before">
|
|
||||||
<xpath
|
|
||||||
expr="//t[@t-marker='unwrap']/div[hasclass('mis_table')]"
|
|
||||||
position="move"
|
|
||||||
/>
|
/>
|
||||||
</xpath>
|
|
||||||
<xpath expr="//t[@t-marker='unwrap']" position="replace" />
|
|
||||||
<xpath expr="//t[@t-marker='wrap_in_table']" position="after">
|
|
||||||
<div t-if="o.horizontal" class="mis_builder_horizontal">
|
|
||||||
<div>
|
|
||||||
<div t-foreach="o._compute_horizontal_matrices()" t-as="matrix" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath expr="//div[hasclass('mis_builder_horizontal_cell')]" position="inside">
|
||||||
expr="//div[hasclass('mis_builder_horizontal')]/div/div"
|
<xpath expr="//div[hasclass('mis_table')]" position="move" />
|
||||||
position="inside"
|
|
||||||
>
|
|
||||||
<xpath expr="//t[@t-marker='wrap_in_table']/div" position="move" />
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//t[@t-marker='wrap_in_table']" position="replace" />
|
<xpath expr="//div[hasclass('mis_table')]" position="attributes">
|
||||||
<xpath
|
<attribute
|
||||||
expr="//div[hasclass('mis_builder_horizontal')]//div[hasclass('mis_table')]"
|
name="t-attf-class"
|
||||||
position="attributes"
|
>mis_table {{o.horizontal and 'horizontal'}}</attribute>
|
||||||
>
|
|
||||||
<attribute name="t-if" />
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue