Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions account_financial_report/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========================
Account Financial Reports
=========================
Expand All @@ -17,7 +13,7 @@ Account Financial Reports
.. |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/license-AGPL--3-blue.png
.. |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-OCA%2Faccount--financial--reporting-lightgray.png?logo=github
Expand Down Expand Up @@ -56,6 +52,10 @@ Invoicing / Settings / Invoicing / OCA Aged Report Configuration you will be abl
dynamic intervals that will appear on the Aged Partner Balance.
For further information, check CONFIGURE.rst

In the Trial Balance, the flag *Hide accounts with 0 end balance*
allows the user to hide accounts that
have ending balance equal to 0 in the selected period.

**Table of contents**

.. contents::
Expand Down Expand Up @@ -195,6 +195,9 @@ Contributors
* Lois Rilo <[email protected]>
* Saran Lim. <[email protected]>
* Omar Castiñeira <[email protected]>
* `PyTech <https://www.pytech.it>`_:

* Simone Rubino <[email protected]>

Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.
Expand Down
3 changes: 3 additions & 0 deletions account_financial_report/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
* Lois Rilo <[email protected]>
* Saran Lim. <[email protected]>
* Omar Castiñeira <[email protected]>
* `PyTech <https://www.pytech.it>`_:

* Simone Rubino <[email protected]>

Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.
Expand Down
4 changes: 4 additions & 0 deletions account_financial_report/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ currency balances are not available.
Invoicing / Settings / Invoicing / OCA Aged Report Configuration you will be able to set
dynamic intervals that will appear on the Aged Partner Balance.
For further information, check CONFIGURE.rst

In the Trial Balance, the flag *Hide accounts with 0 end balance*
allows the user to hide accounts that
have ending balance equal to 0 in the selected period.
71 changes: 60 additions & 11 deletions account_financial_report/report/trial_balance.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# © 2016 Julien Coux (Camptocamp)
# © 2018 Forest and Biomass Romania SA
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2025 Simone Rubino - PyTech
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from odoo import _, api, models
from odoo import _, api, exceptions, models
from odoo.exceptions import UserError
from odoo.tools.float_utils import float_is_zero

Expand Down Expand Up @@ -375,27 +376,65 @@ def _compute_partner_amount(
total_amount[acc_id][key] = value
return total_amount, partners_data

def _remove_accounts_at_cero(self, total_amount, show_partner_details, company):
def is_removable(d):
rounding = company.currency_id.rounding
return (
float_is_zero(d["initial_balance"], precision_rounding=rounding)
and float_is_zero(d["credit"], precision_rounding=rounding)
and float_is_zero(d["debit"], precision_rounding=rounding)
and float_is_zero(d["ending_balance"], precision_rounding=rounding)
def _is_removable(self, company, total_account_data, amounts_at_0):
"""Return True when all keys in `amounts_at_0` have value 0 in `total_account_data`.

The precision of `company`'s currency is used to check the values.
"""
rounding = company.currency_id.rounding
is_to_remove = False
for amount_at_0 in amounts_at_0:
if not float_is_zero(
total_account_data[amount_at_0],
precision_rounding=rounding,
):
is_to_remove = False
break
else:
# All amounts are 0
is_to_remove = True
return is_to_remove

def _get_amounts_at_0_to_remove_account_data(self, mode):
"""Return the amounts that must be checked for removing account lines."""
mode_to_amounts_at_0 = {
"all": [
"initial_balance",
"credit",
"debit",
"ending_balance",
],
"end": [
"ending_balance",
],
}
amounts_at_0 = mode_to_amounts_at_0.get(mode, [])
if not amounts_at_0:
raise exceptions.UserError(
_(
"Mode %(mode)s for removing account lines at 0 not supported",
mode=mode,
)
)
return amounts_at_0

def _remove_accounts_at_cero(
self, total_amount, show_partner_details, company, mode="all"
):
amounts_at_0 = self._get_amounts_at_0_to_remove_account_data(mode=mode)
accounts_to_remove = []
for acc_id, ta_data in total_amount.items():
if is_removable(ta_data):
if self._is_removable(company, ta_data, amounts_at_0):
accounts_to_remove.append(acc_id)
elif show_partner_details:
partner_to_remove = []
for key, value in ta_data.items():
# If the show_partner_details option is checked,
# the partner data is in the same account data dict
# but with the partner id as the key
if isinstance(key, int) and is_removable(value):
if isinstance(key, int) and self._is_removable(
company, value, amounts_at_0
):
partner_to_remove.append(key)
for partner_id in partner_to_remove:
del ta_data[partner_id]
Expand All @@ -416,6 +455,7 @@ def _get_data(
only_posted_moves,
show_partner_details,
hide_account_at_0,
hide_account_at_end_0,
unaffected_earnings_account,
fy_start_date,
grouped_by,
Expand Down Expand Up @@ -549,6 +589,12 @@ def _get_data(
total_amount, tb_initial_prt, tb_period_prt, foreign_currency
)
# Remove accounts a 0 from collections
if hide_account_at_end_0:
company = self.env["res.company"].browse(company_id)
self._remove_accounts_at_cero(
total_amount, show_partner_details, company, mode="end"
)

if hide_account_at_0:
company = self.env["res.company"].browse(company_id)
self._remove_accounts_at_cero(total_amount, show_partner_details, company)
Expand Down Expand Up @@ -872,6 +918,7 @@ def _get_report_values(self, docids, data):
date_to = data["date_to"]
date_from = data["date_from"]
hide_account_at_0 = data["hide_account_at_0"]
hide_account_at_end_0 = data["hide_account_at_end_0"]
show_hierarchy = data["show_hierarchy"]
show_hierarchy_level = data["show_hierarchy_level"]
foreign_currency = data["foreign_currency"]
Expand All @@ -890,6 +937,7 @@ def _get_report_values(self, docids, data):
only_posted_moves,
show_partner_details,
hide_account_at_0,
hide_account_at_end_0,
unaffected_earnings_account,
fy_start_date,
grouped_by,
Expand Down Expand Up @@ -969,6 +1017,7 @@ def _get_report_values(self, docids, data):
"date_to": data["date_to"],
"only_posted_moves": data["only_posted_moves"],
"hide_account_at_0": data["hide_account_at_0"],
"hide_account_at_end_0": data["hide_account_at_end_0"],
"show_partner_details": data["show_partner_details"],
"limit_hierarchy_level": data["limit_hierarchy_level"],
"show_hierarchy": show_hierarchy,
Expand Down
45 changes: 23 additions & 22 deletions account_financial_report/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Account Financial Reports</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="account-financial-reports">
<h1 class="title">Account Financial Reports</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="account-financial-reports">
<h1>Account Financial Reports</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c5ecd2feb52f6759a0fd2a646e74df587e732710b344ae0d124c228b62098e2a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-reporting/tree/16.0/account_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-account_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&amp;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/account_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-account_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&amp;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 module adds a set of financial reports. They are accessible under
Invoicing / Reporting / OCA accounting reports.</p>
<ul class="simple">
Expand All @@ -395,6 +390,9 @@ <h1>Account Financial Reports</h1>
<p>Invoicing / Settings / Invoicing / OCA Aged Report Configuration you will be able to set
dynamic intervals that will appear on the Aged Partner Balance.
For further information, check CONFIGURE.rst</p>
<p>In the Trial Balance, the flag <em>Hide accounts with 0 end balance</em>
allows the user to hide accounts that
have ending balance equal to 0 in the selected period.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -417,7 +415,7 @@ <h1>Account Financial Reports</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure dynamic intervals for Aged Partner Balance you need to:</p>
<p>Go on ‘Settings’ -&gt; ‘Invoicing’ -&gt; ‘OCA Aged Report Configuration’.</p>
<p>Click on option ‘Configurations’ and create new record.</p>
Expand All @@ -436,7 +434,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>‘Settings’ -&gt; ‘Invoicing’ -&gt; ‘OCA Aged Report Configuration’.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>‘VAT Report’ is valid only for cases where it’s met that for each
Tax defined: all the “Account tags” of all the
Expand All @@ -451,29 +449,29 @@ <h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
</ul>
</div>
<div class="section" id="changelog">
<h2><a class="toc-backref" href="#toc-entry-3">Changelog</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Changelog</a></h1>
<div class="section" id="section-1">
<h3><a class="toc-backref" href="#toc-entry-4">15.0.3.2.3 (2025-02-17)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">15.0.3.2.3 (2025-02-17)</a></h2>
<ul class="simple">
<li>Added the option to select columns to display and the ability to limit the width of the text</li>
</ul>
</div>
<div class="section" id="section-2">
<h3><a class="toc-backref" href="#toc-entry-5">11.0.2.5.0 (2019-04-26)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">11.0.2.5.0 (2019-04-26)</a></h2>
<ul class="simple">
<li>In the Trial Balance you have an option to hide parent hierarchy levels</li>
</ul>
</div>
<div class="section" id="section-3">
<h3><a class="toc-backref" href="#toc-entry-6">11.0.2.4.1 (2019-01-08)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">11.0.2.4.1 (2019-01-08)</a></h2>
<ul class="simple">
<li>Handle better multicompany behaviour</li>
<li>Improve how title appears in the reports</li>
<li>Improve performance in General Ledger</li>
</ul>
</div>
<div class="section" id="section-4">
<h3><a class="toc-backref" href="#toc-entry-7">11.0.2.3.1 (2018-11-29)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">11.0.2.3.1 (2018-11-29)</a></h2>
<ul class="simple">
<li>In the Trial Balance you can apply a filter by hierarchy levels</li>
<li>In the General Ledger you can apply a filter by Analytic Tag</li>
Expand All @@ -482,17 +480,17 @@ <h3><a class="toc-backref" href="#toc-entry-7">11.0.2.3.1 (2018-11-29)</a></h3>
</div>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-8">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-8">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_financial_report%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-9">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-9">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-10">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-10">Authors</a></h2>
<ul class="simple">
<li>Camptocamp</li>
<li>initOS GmbH</li>
Expand All @@ -502,7 +500,7 @@ <h3><a class="toc-backref" href="#toc-entry-10">Authors</a></h3>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-11">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-11">Contributors</a></h2>
<ul class="simple">
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Yannick Vaucher &lt;<a class="reference external" href="mailto:yannick.vaucher&#64;camptocamp.com">yannick.vaucher&#64;camptocamp.com</a>&gt;</li>
Expand Down Expand Up @@ -541,6 +539,10 @@ <h3><a class="toc-backref" href="#toc-entry-11">Contributors</a></h3>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li>Omar Castiñeira &lt;<a class="reference external" href="mailto:omar&#64;comunitea.com">omar&#64;comunitea.com</a>&gt;</li>
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
</ul>
</li>
</ul>
<p>Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.</p>
Expand All @@ -552,7 +554,7 @@ <h3><a class="toc-backref" href="#toc-entry-11">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -565,6 +567,5 @@ <h3><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
Loading