-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from Escodoo/14.0-add-mis_builder_custom_reports
[14.0][ADD] mis_builder_custom_reports: add new module
- Loading branch information
Showing
18 changed files
with
796 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
========================== | ||
MIS Builder Custom Reports | ||
========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c309fd02cb551b03bdcd5e50d341d3f242b34340e8e2e2af9ae7e4ecd3b411c9 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-Escodoo%2Faccount--addons-lightgray.png?logo=github | ||
:target: https://github.com/Escodoo/account-addons/tree/14.0/mis_builder_custom_reports | ||
:alt: Escodoo/account-addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module includes some changes in MIS Builder Reports. | ||
|
||
- Exclude KPIs with name `check` when export to PDF. | ||
- Change KPI description from Profit to Loss when the sum of the row is negative. | ||
- Add custom header and footer to MIS Builder PDF Report. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
- Create KPIs for checking results using the name `check`, this KPIs will be invisible when export to PDF. | ||
- Check the "Is Profit or Loss?" field. | ||
- Fill the description with the key word `Lucro` (Profit). | ||
- This word will change to `Prejuizo` (Loss) when the sum of the row is negative. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/Escodoo/account-addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`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**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Escodoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Wesley Oliveira <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
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. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2024 - TODAY, Escodoo | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "MIS Builder Custom Reports", | ||
"summary": """ | ||
MIS Builder Custom Reports""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Escodoo", | ||
"website": "https://github.com/Escodoo/account-addons", | ||
"depends": ["mis_builder"], | ||
"data": [ | ||
"views/mis_report.xml", | ||
"report/mis_report_instance_qweb.xml", | ||
], | ||
"demo": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mis_builder_custom_reports | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-11-08 20:40+0000\n" | ||
"PO-Revision-Date: 2024-11-08 20:40+0000\n" | ||
"Last-Translator: Wesley Oliveira, 2024" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model_terms:ir.ui.view,arch_db:mis_builder_custom_reports.report_mis_report_instance | ||
msgid "<span>(In thousands of reais - R$)</span>" | ||
msgstr "<span>(Em milhares de reais - R$)</span>" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi__display_name | ||
msgid "Display Name" | ||
msgstr "Exibir Nome" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi__is_profit_loss | ||
msgid "Is Profit or Loss?" | ||
msgstr "É Lucro ou Prejuizo?" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model:ir.model.fields,field_description:mis_builder_custom_reports.field_mis_report_kpi____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última atualização em" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model_terms:ir.ui.view,arch_db:mis_builder_custom_reports.report_mis_report_instance | ||
msgid "Logo" | ||
msgstr "" | ||
|
||
#. module: mis_builder_custom_reports | ||
#: model:ir.model,name:mis_builder_custom_reports.model_mis_report_kpi | ||
msgid "MIS Report KPI" | ||
msgstr "Relatório KPI" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import kpimatrix | ||
from . import mis_report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.addons.mis_builder.models.kpimatrix import KpiMatrixRow | ||
|
||
|
||
def sum_row(self): | ||
cells = self.iter_cells() | ||
total = 0 | ||
for cell in cells: | ||
if cell and cell.val not in (None, "AccountingNone"): | ||
total += float(cell.val) | ||
return total | ||
|
||
|
||
@property | ||
def custom_label(self): | ||
label = self.kpi.description | ||
if self.account_id: | ||
label = self._matrix.get_account_name(self.account_id) | ||
|
||
if self.sum_row() < 0 and self.kpi.is_profit_loss: | ||
return label.replace("Lucro", "Prejuízo") | ||
return label | ||
|
||
|
||
KpiMatrixRow.sum_row = sum_row | ||
KpiMatrixRow.label = custom_label |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]> | ||
# 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" | ||
|
||
is_profit_loss = fields.Boolean(string="Is Profit or Loss?", default=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Wesley Oliveira <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This module includes some changes in MIS Builder Reports. | ||
|
||
- Exclude KPIs with name `check` when export to PDF. | ||
- Change KPI description from Profit to Loss when the sum of the row is negative. | ||
- Add custom header and footer to MIS Builder PDF Report. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
To use this module, you need to: | ||
|
||
- Create KPIs for checking results using the name `check`, this KPIs will be invisible when export to PDF. | ||
- Check the "Is Profit or Loss?" field. | ||
- Fill the description with the key word `Lucro` (Profit). | ||
- This word will change to `Prejuizo` (Loss) when the sum of the row is negative. |
113 changes: 113 additions & 0 deletions
113
mis_builder_custom_reports/report/mis_report_instance_qweb.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- Copyright 2024 - TODAY, Wesley Oliveira <[email protected]> | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<template | ||
id="assets_report" | ||
name="mis_builder_custom_reports" | ||
inherit_id="web.report_assets_common" | ||
> | ||
<xpath expr="." position="inside"> | ||
<link | ||
href="/mis_builder_custom_reports/static/src/css/report.css" | ||
rel="stylesheet" | ||
/> | ||
</xpath> | ||
</template> | ||
<template | ||
id="report_mis_report_instance" | ||
inherit_id="mis_builder.report_mis_report_instance" | ||
> | ||
<xpath expr="//t[@t-call='web.internal_layout']" position="attributes"> | ||
<attribute name="t-call">web.basic_layout</attribute> | ||
</xpath> | ||
<xpath expr="//div[@class='page']" position="before"> | ||
<t t-set="company_id" t-value="o.query_company_ids[0]" /> | ||
<div | ||
t-attf-class="header o_company_#{company_id.id}_layout" | ||
t-att-style="report_header_style" | ||
> | ||
<div class="row mb-3"> | ||
<div class="col-3"> | ||
<t t-set="company_id" t-value="o.query_company_ids[0]" /> | ||
<img | ||
t-if="company_id.logo" | ||
t-att-src="image_data_uri(company_id.logo)" | ||
style="max-height: 45px; border-right: 1px solid gray;" | ||
alt="Logo" | ||
/> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<span | ||
style="text-decoration: underline; text-transform: uppercase;" | ||
t-field="company_id.legal_name" | ||
/> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<span | ||
style="text-transform: uppercase;" | ||
t-field="o.description" | ||
/> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<span>(In thousands of reais - R$)</span> | ||
</div> | ||
</div> | ||
<div | ||
t-if="company_id.logo or company_id.report_header" | ||
class="row zero_min_height" | ||
> | ||
<div class="col-12"> | ||
<div style="border-bottom: 1px solid black;" /> | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
<xpath expr="//div[@class='page']/h3" position="replace"> | ||
<h3 /> | ||
</xpath> | ||
<xpath | ||
expr="//div[hasclass('mis_tbody')]/t[@t-as='row']/div[hasclass('mis_row')]" | ||
position="attributes" | ||
> | ||
<attribute name="t-if"> | ||
not ((row.style_props.hide_empty and row.is_empty()) | ||
or row.style_props.hide_always) and row.row_id != "check" | ||
</attribute> | ||
</xpath> | ||
<xpath expr="//div[@class='page']/h3" position="after"> | ||
<div | ||
t-attf-class="footer o_standard_footer o_company_#{company_id.id}_layout" | ||
> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<span | ||
style="text-decoration: underline; text-transform: uppercase;" | ||
t-field="company_id.legal_name" | ||
/> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-12" name="company_address"> | ||
<span t-field="company_id.partner_id.street_name" />, | ||
<span t-field="company_id.partner_id.street_number" />, | ||
<t t-if="company_id.partner_id.street2"> | ||
<span t-field="company_id.partner_id.street2" />, | ||
</t> | ||
<span t-field="company_id.partner_id.district" />, | ||
<span t-field="company_id.partner_id.zip" />, | ||
<span t-field="company_id.partner_id.city_id.name" /> - | ||
<span t-field="company_id.partner_id.state_id.name" />, | ||
<span t-field="company_id.partner_id.country_id.name" /> | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</template> | ||
</odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.