Skip to content

Commit 22d8492

Browse files
[ADD] mis_builder_custom_reports: add new module
1 parent 0e623a4 commit 22d8492

File tree

18 files changed

+796
-0
lines changed

18 files changed

+796
-0
lines changed

mis_builder_custom_reports/README.rst

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
==========================
2+
MIS Builder Custom Reports
3+
==========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:c309fd02cb551b03bdcd5e50d341d3f242b34340e8e2e2af9ae7e4ecd3b411c9
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-Escodoo%2Faccount--addons-lightgray.png?logo=github
20+
:target: https://github.com/Escodoo/account-addons/tree/14.0/mis_builder_custom_reports
21+
:alt: Escodoo/account-addons
22+
23+
|badge1| |badge2| |badge3|
24+
25+
This module includes some changes in MIS Builder Reports.
26+
27+
- Exclude KPIs with name `check` when export to PDF.
28+
- Change KPI description from Profit to Loss when the sum of the row is negative.
29+
- Add custom header and footer to MIS Builder PDF Report.
30+
31+
**Table of contents**
32+
33+
.. contents::
34+
:local:
35+
36+
Usage
37+
=====
38+
39+
To use this module, you need to:
40+
41+
- Create KPIs for checking results using the name `check`, this KPIs will be invisible when export to PDF.
42+
- Check the "Is Profit or Loss?" field.
43+
- Fill the description with the key word `Lucro` (Profit).
44+
- This word will change to `Prejuizo` (Loss) when the sum of the row is negative.
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/Escodoo/account-addons/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us to smash it by providing a detailed and welcomed
52+
`feedback <https://github.com/Escodoo/account-addons/issues/new?body=module:%20mis_builder_custom_reports%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
54+
Do not contact contributors directly about support or help with technical issues.
55+
56+
Credits
57+
=======
58+
59+
Authors
60+
~~~~~~~
61+
62+
* Escodoo
63+
64+
Contributors
65+
~~~~~~~~~~~~
66+
67+
* `Escodoo <https://www.escodoo.com.br>`_:
68+
69+
* Marcel Savegnago <[email protected]>
70+
* Wesley Oliveira <[email protected]>
71+
72+
Maintainers
73+
~~~~~~~~~~~
74+
75+
This module is part of the `Escodoo/account-addons <https://github.com/Escodoo/account-addons/tree/14.0/mis_builder_custom_reports>`_ project on GitHub.
76+
77+
You are welcome to contribute.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2024 - TODAY, Escodoo
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "MIS Builder Custom Reports",
6+
"summary": """
7+
MIS Builder Custom Reports""",
8+
"version": "14.0.1.0.0",
9+
"license": "AGPL-3",
10+
"author": "Escodoo",
11+
"website": "https://github.com/Escodoo/account-addons",
12+
"depends": ["mis_builder"],
13+
"data": [
14+
"views/mis_report.xml",
15+
"report/mis_report_instance_qweb.xml",
16+
],
17+
"demo": [],
18+
}
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * mis_builder_custom_reports
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 14.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2024-11-08 20:40+0000\n"
10+
"PO-Revision-Date: 2024-11-08 20:40+0000\n"
11+
"Last-Translator: Wesley Oliveira, 2024"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: mis_builder_custom_reports
19+
#: model_terms:ir.ui.view,arch_db:mis_builder_custom_reports.report_mis_report_instance
20+
msgid "<span>(In thousands of reais - R$)</span>"
21+
msgstr "<span>(Em milhares de reais - R$)</span>"
22+
23+
#. module: mis_builder_custom_reports
24+
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi__display_name
25+
msgid "Display Name"
26+
msgstr "Exibir Nome"
27+
28+
#. module: mis_builder_custom_reports
29+
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi__id
30+
msgid "ID"
31+
msgstr ""
32+
33+
#. module: mis_builder_custom_reports
34+
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi__is_profit_loss
35+
msgid "Is Profit or Loss?"
36+
msgstr "É Lucro ou Prejuizo?"
37+
38+
#. module: mis_builder_custom_reports
39+
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi____last_update
40+
msgid "Last Modified on"
41+
msgstr "Última atualização em"
42+
43+
#. module: mis_builder_custom_reports
44+
#: model_terms:ir.ui.view,arch_db:mis_builder_custom_reports.report_mis_report_instance
45+
msgid "Logo"
46+
msgstr ""
47+
48+
#. module: mis_builder_custom_reports
49+
#: model:ir.model,name:mis_builder_custom_reports.model_mis_report_kpi
50+
msgid "MIS Report KPI"
51+
msgstr "Relatório KPI"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import kpimatrix
2+
from . import mis_report
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo.addons.mis_builder.models.kpimatrix import KpiMatrixRow
5+
6+
7+
def sum_row(self):
8+
cells = self.iter_cells()
9+
total = 0
10+
for cell in cells:
11+
if cell and cell.val not in (None, "AccountingNone"):
12+
total += float(cell.val)
13+
return total
14+
15+
16+
@property
17+
def custom_label(self):
18+
label = self.kpi.description
19+
if self.account_id:
20+
label = self._matrix.get_account_name(self.account_id)
21+
22+
if self.sum_row() < 0 and self.kpi.is_profit_loss:
23+
return label.replace("Lucro", "Prejuízo")
24+
return label
25+
26+
27+
KpiMatrixRow.sum_row = sum_row
28+
KpiMatrixRow.label = custom_label
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class MisReportKpi(models.Model):
8+
9+
_inherit = "mis.report.kpi"
10+
11+
is_profit_loss = fields.Boolean(string="Is Profit or Loss?", default=False)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `Escodoo <https://www.escodoo.com.br>`_:
2+
3+
* Marcel Savegnago <[email protected]>
4+
* Wesley Oliveira <[email protected]>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This module includes some changes in MIS Builder Reports.
2+
3+
- Exclude KPIs with name `check` when export to PDF.
4+
- Change KPI description from Profit to Loss when the sum of the row is negative.
5+
- Add custom header and footer to MIS Builder PDF Report.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To use this module, you need to:
2+
3+
- Create KPIs for checking results using the name `check`, this KPIs will be invisible when export to PDF.
4+
- Check the "Is Profit or Loss?" field.
5+
- Fill the description with the key word `Lucro` (Profit).
6+
- This word will change to `Prejuizo` (Loss) when the sum of the row is negative.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- Copyright 2024 - TODAY, Wesley Oliveira <[email protected]>
3+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
4+
<odoo>
5+
<template
6+
id="assets_report"
7+
name="mis_builder_custom_reports"
8+
inherit_id="web.report_assets_common"
9+
>
10+
<xpath expr="." position="inside">
11+
<link
12+
href="/mis_builder_custom_reports/static/src/css/report.css"
13+
rel="stylesheet"
14+
/>
15+
</xpath>
16+
</template>
17+
<template
18+
id="report_mis_report_instance"
19+
inherit_id="mis_builder.report_mis_report_instance"
20+
>
21+
<xpath expr="//t[@t-call='web.internal_layout']" position="attributes">
22+
<attribute name="t-call">web.basic_layout</attribute>
23+
</xpath>
24+
<xpath expr="//div[@class='page']" position="before">
25+
<t t-set="company_id" t-value="o.query_company_ids[0]" />
26+
<div
27+
t-attf-class="header o_company_#{company_id.id}_layout"
28+
t-att-style="report_header_style"
29+
>
30+
<div class="row mb-3">
31+
<div class="col-3">
32+
<t t-set="company_id" t-value="o.query_company_ids[0]" />
33+
<img
34+
t-if="company_id.logo"
35+
t-att-src="image_data_uri(company_id.logo)"
36+
style="max-height: 45px; border-right: 1px solid gray;"
37+
alt="Logo"
38+
/>
39+
</div>
40+
</div>
41+
<div class="row">
42+
<div class="col-12">
43+
<span
44+
style="text-decoration: underline; text-transform: uppercase;"
45+
t-field="company_id.legal_name"
46+
/>
47+
</div>
48+
</div>
49+
<div class="row">
50+
<div class="col-12">
51+
<span
52+
style="text-transform: uppercase;"
53+
t-field="o.description"
54+
/>
55+
</div>
56+
</div>
57+
<div class="row">
58+
<div class="col-12">
59+
<span>(In thousands of reais - R$)</span>
60+
</div>
61+
</div>
62+
<div
63+
t-if="company_id.logo or company_id.report_header"
64+
class="row zero_min_height"
65+
>
66+
<div class="col-12">
67+
<div style="border-bottom: 1px solid black;" />
68+
</div>
69+
</div>
70+
</div>
71+
</xpath>
72+
<xpath expr="//div[@class='page']/h3" position="replace">
73+
<h3 />
74+
</xpath>
75+
<xpath
76+
expr="//div[hasclass('mis_tbody')]/t[@t-as='row']/div[hasclass('mis_row')]"
77+
position="attributes"
78+
>
79+
<attribute name="t-if">
80+
not ((row.style_props.hide_empty and row.is_empty())
81+
or row.style_props.hide_always) and row.row_id != "check"
82+
</attribute>
83+
</xpath>
84+
<xpath expr="//div[@class='page']/h3" position="after">
85+
<div
86+
t-attf-class="footer o_standard_footer o_company_#{company_id.id}_layout"
87+
>
88+
<div class="row">
89+
<div class="col-12">
90+
<span
91+
style="text-decoration: underline; text-transform: uppercase;"
92+
t-field="company_id.legal_name"
93+
/>
94+
</div>
95+
</div>
96+
<div class="row">
97+
<div class="col-12" name="company_address">
98+
<span t-field="company_id.partner_id.street_name" />,
99+
<span t-field="company_id.partner_id.street_number" />,
100+
<t t-if="company_id.partner_id.street2">
101+
<span t-field="company_id.partner_id.street2" />,
102+
</t>
103+
<span t-field="company_id.partner_id.district" />,
104+
<span t-field="company_id.partner_id.zip" />,
105+
<span t-field="company_id.partner_id.city_id.name" /> -
106+
<span t-field="company_id.partner_id.state_id.name" />,
107+
<span t-field="company_id.partner_id.country_id.name" />
108+
</div>
109+
</div>
110+
</div>
111+
</xpath>
112+
</template>
113+
</odoo>
Loading

0 commit comments

Comments
 (0)