Skip to content

Commit

Permalink
[MIG] account_financial_report: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chaule97 committed Nov 29, 2024
1 parent ddbfd5a commit f403480
Show file tree
Hide file tree
Showing 43 changed files with 292 additions and 220 deletions.
11 changes: 9 additions & 2 deletions account_financial_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Example of configuration inferior limit:
It means the first interval is from 0 to 15, the second from 16 to 30,
and the third is 61+.

Go on 'Invoicing' -> 'Reports' -> 'OCA accounting reports' -> 'Aged
Go on 'Invoicing' -> 'Reporting' -> 'OCA accounting reports' -> 'Aged
Partner Balance'

When wizard is open, you need to select your interval configuration and
Expand Down Expand Up @@ -167,7 +167,7 @@ Contributors
- Pedro M. Baeza
- Sergio Teruel
- Ernesto Tejeda
- Jo??o Marques
- João Marques
- Alexandre D. D??az
- V??ctor Mart??nez
- Carolina Fernandez
Expand All @@ -180,10 +180,17 @@ Contributors
- Lois Rilo <[email protected]>
- Saran Lim. <[email protected]>
- Omar Casti??eira <[email protected]>
- Chau Le <[email protected]>

Much of the work in this module was done at a sprint in Sorrento, Italy
in April 2016.

Other credits
-------------

The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------

Expand Down
5 changes: 3 additions & 2 deletions account_financial_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# Copyright 2021 Tecnativa - Jo??o Marques
# Copyright 2021 Tecnativa - João Marques
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Financial Reports",
"version": "17.0.1.5.0",
"version": "18.0.0.1.0",
"category": "Reporting",
"summary": "OCA Financial Reports",
"author": "Camptocamp,"
Expand Down Expand Up @@ -47,6 +47,7 @@
"assets": {
"web.assets_backend": [
"account_financial_report/static/src/js/*",
"account_financial_report/static/src/scss/*",
"account_financial_report/static/src/xml/**/*",
],
},
Expand Down
2 changes: 1 addition & 1 deletion account_financial_report/models/account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ?? 2011 Guewen Baconnier (Camptocamp)
# © 2011 Guewen Baconnier (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import fields, models

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 Ernesto García
# Copyright 2023 Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand All @@ -21,7 +21,7 @@ class AccountAgeReportConfiguration(models.Model):
def _check_line_ids(self):
for rec in self:
if not rec.line_ids:
raise ValidationError(_("Must complete Configuration Lines"))
raise ValidationError(self.env._("Must complete Configuration Lines"))


class AccountAgeReportConfigurationLine(models.Model):
Expand All @@ -36,12 +36,14 @@ class AccountAgeReportConfigurationLine(models.Model):
def _check_inferior_limit(self):
for rec in self:
if rec.inferior_limit <= 0:
raise ValidationError(_("Inferior Limit must be greather than zero"))
raise ValidationError(
self.env._("Inferior Limit must be greather than zero")
)

_sql_constraints = [
(
"unique_name_config_combination",
"UNIQUE(name,account_age_report_config_id)",
_("Name must be unique per report configuration"),
"Name must be unique per report configuration",
)
]
2 changes: 1 addition & 1 deletion account_financial_report/models/account_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ?? 2018 Forest and Biomass Romania SA
# © 2018 Forest and Biomass Romania SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
Expand Down
2 changes: 1 addition & 1 deletion account_financial_report/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Example of configuration inferior limit:

It means the first interval is from 0 to 15, the second from 16 to 30, and the third is 61+.

Go on 'Invoicing' -> 'Reports' -> 'OCA accounting reports' -> 'Aged Partner Balance'
Go on 'Invoicing' -> 'Reporting' -> 'OCA accounting reports' -> 'Aged Partner Balance'

When wizard is open, you need to select your interval configuration and print report.

Expand Down
3 changes: 2 additions & 1 deletion account_financial_report/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- Pedro M. Baeza
- Sergio Teruel
- Ernesto Tejeda
- Jo??o Marques
- João Marques
- Alexandre D. D??az
- V??ctor Mart??nez
- Carolina Fernandez
Expand All @@ -30,6 +30,7 @@
- Lois Rilo \<<[email protected]>\>
- Saran Lim. \<<[email protected]>\>
- Omar Casti??eira \<<[email protected]>\>
- Chau Le \<<[email protected]>\>

Much of the work in this module was done at a sprint in Sorrento, Italy
in April 2016.
1 change: 1 addition & 0 deletions account_financial_report/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.
6 changes: 3 additions & 3 deletions account_financial_report/report/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ?? 2015 Yannick Vaucher (Camptocamp)
# ?? 2016 Damien Crier (Camptocamp)
# ?? 2016 Julien Coux (Camptocamp)
# © 2015 Yannick Vaucher (Camptocamp)
# © 2016 Damien Crier (Camptocamp)
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-

from . import abstract_report
Expand Down
4 changes: 3 additions & 1 deletion account_financial_report/report/abstract_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def _get_accounts_data(self, accounts_ids):
return accounts_data

def _get_journals_data(self, journals_ids):
journals = self.env["account.journal"].browse(journals_ids)
journals = self.env["account.journal"].search_fetch(
[("id", "in", journals_ids)], ["code"]
)
journals_data = {}
for journal in journals:
journals_data.update({journal.id: {"id": journal.id, "code": journal.code}})
Expand Down
6 changes: 3 additions & 3 deletions account_financial_report/report/abstract_report_xlsx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# Copyright 2021 Tecnativa - Jo??o Marques
# Copyright 2021 Tecnativa - João Marques
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models

Expand Down Expand Up @@ -571,7 +571,7 @@ def _get_currency_amt_header_format(self, line_object, report_data):
"""Return amount header format for each currency."""
format_amt = report_data["formats"]["format_header_amount"]

Check warning on line 572 in account_financial_report/report/abstract_report_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/abstract_report_xlsx.py#L572

Added line #L572 was not covered by tests
if line_object.currency_id:
field_name = "format_header_amount_%s" % line_object.currency_id.name
field_name = f"format_header_amount_{line_object.currency_id.name}"

Check warning on line 574 in account_financial_report/report/abstract_report_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/abstract_report_xlsx.py#L574

Added line #L574 was not covered by tests
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
Expand All @@ -589,7 +589,7 @@ def _get_currency_amt_header_format_dict(self, line_object, report_data):
"""Return amount header format for each currency."""
format_amt = report_data["formats"]["format_header_amount"]

Check warning on line 590 in account_financial_report/report/abstract_report_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/abstract_report_xlsx.py#L590

Added line #L590 was not covered by tests
if line_object["currency_id"]:
field_name = "format_header_amount_%s" % line_object["currency_name"]
field_name = f"format_header_amount_{line_object['currency_name']}"

Check warning on line 592 in account_financial_report/report/abstract_report_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/abstract_report_xlsx.py#L592

Added line #L592 was not covered by tests
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
Expand Down
36 changes: 16 additions & 20 deletions account_financial_report/report/aged_partner_balance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ?? 2016 Julien Coux (Camptocamp)
# © 2016 Julien Coux (Camptocamp)
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

Expand Down Expand Up @@ -72,25 +72,21 @@ def _calculate_amounts(
else:
ag_pb_data[acc_id]["older"] += residual
ag_pb_data[acc_id][prt_id]["older"] += residual

Check warning on line 74 in account_financial_report/report/aged_partner_balance.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance.py#L73-L74

Added lines #L73 - L74 were not covered by tests
if due_date:
days_difference = abs((today - due_date).days)
for index, line in enumerate(interval_lines):
lower_limit = (
0 if not index else interval_lines[index - 1].inferior_limit
)
next_line = (
interval_lines[index] if index < len(interval_lines) else None
)
interval_range = self._get_values_for_range_intervals(
lower_limit, next_line.inferior_limit
)
if (
days_difference in interval_range
or days_difference == line.inferior_limit
):
ag_pb_data[acc_id][line] += residual
ag_pb_data[acc_id][prt_id][line] += residual
break

days_difference = abs((today - due_date).days)
for index, line in enumerate(interval_lines):
lower_limit = 0 if not index else interval_lines[index - 1].inferior_limit
next_line = interval_lines[index] if index < len(interval_lines) else None
interval_range = self._get_values_for_range_intervals(
lower_limit, next_line.inferior_limit
)
if (
days_difference in interval_range
or days_difference == line.inferior_limit
):
ag_pb_data[acc_id][line] += residual
ag_pb_data[acc_id][prt_id][line] += residual
break
return ag_pb_data

def _get_values_for_range_intervals(self, num1, num2):
Expand Down
Loading

0 comments on commit f403480

Please sign in to comment.