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 21, 2024
1 parent a10c361 commit befa9ce
Show file tree
Hide file tree
Showing 29 changed files with 231 additions and 169 deletions.
9 changes: 8 additions & 1 deletion 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 @@ -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
3 changes: 2 additions & 1 deletion account_financial_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Financial Reports",
"version": "17.0.1.4.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
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/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
1 change: 1 addition & 0 deletions account_financial_report/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions account_financial_report/report/abstract_report_xlsx.py
Original file line number Diff line number Diff line change
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
58 changes: 29 additions & 29 deletions account_financial_report/report/aged_partner_balance_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2021 Tecnativa - Jo??o Marques
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, models
from odoo import models


class AgedPartnerBalanceXslx(models.AbstractModel):
Expand All @@ -13,7 +13,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):

def _get_report_name(self, report, data=False):
company_id = data.get("company_id", False)
report_name = _("Aged Partner Balance")
report_name = self.env._("Aged Partner Balance")

Check warning on line 16 in account_financial_report/report/aged_partner_balance_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance_xlsx.py#L15-L16

Added lines #L15 - L16 were not covered by tests
if company_id:
company = self.env["res.company"].browse(company_id)
suffix = f" - {company.name} - {company.currency_id.name}"
Expand All @@ -22,16 +22,16 @@ def _get_report_name(self, report, data=False):

def _get_report_columns_without_move_line_details(self, report, column_index):
report_columns = {

Check warning on line 24 in account_financial_report/report/aged_partner_balance_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance_xlsx.py#L24

Added line #L24 was not covered by tests
0: {"header": _("Partner"), "field": "name", "width": 70},
0: {"header": self.env._("Partner"), "field": "name", "width": 70},
1: {
"header": _("Residual"),
"header": self.env._("Residual"),
"field": "residual",
"field_footer_total": "residual",
"type": "amount",
"width": 14,
},
2: {
"header": _("Current"),
"header": self.env._("Current"),
"field": "current",
"field_footer_total": "current",
"field_footer_percent": "percent_current",
Expand All @@ -43,39 +43,39 @@ def _get_report_columns_without_move_line_details(self, report, column_index):
report_columns.update(

Check warning on line 43 in account_financial_report/report/aged_partner_balance_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance_xlsx.py#L43

Added line #L43 was not covered by tests
{
3: {
"header": _("Age ≤ 30 d."),
"header": self.env._("Age ≤ 30 d."),
"field": "30_days",
"field_footer_total": "30_days",
"field_footer_percent": "percent_30_days",
"type": "amount",
"width": 14,
},
4: {
"header": _("Age ≤ 60 d."),
"header": self.env._("Age ≤ 60 d."),
"field": "60_days",
"field_footer_total": "60_days",
"field_footer_percent": "percent_60_days",
"type": "amount",
"width": 14,
},
5: {
"header": _("Age ≤ 90 d."),
"header": self.env._("Age ≤ 90 d."),
"field": "90_days",
"field_footer_total": "90_days",
"field_footer_percent": "percent_90_days",
"type": "amount",
"width": 14,
},
6: {
"header": _("Age ≤ 120 d."),
"header": self.env._("Age ≤ 120 d."),
"field": "120_days",
"field_footer_total": "120_days",
"field_footer_percent": "percent_120_days",
"type": "amount",
"width": 14,
},
7: {
"header": _("Older"),
"header": self.env._("Older"),
"field": "older",
"field_footer_total": "older",
"field_footer_percent": "percent_older",
Expand All @@ -98,23 +98,23 @@ def _get_report_columns_without_move_line_details(self, report, column_index):

def _get_report_columns_with_move_line_details(self, report, column_index):
report_columns = {

Check warning on line 100 in account_financial_report/report/aged_partner_balance_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance_xlsx.py#L100

Added line #L100 was not covered by tests
0: {"header": _("Date"), "field": "date", "width": 11},
1: {"header": _("Entry"), "field": "entry", "width": 18},
2: {"header": _("Journal"), "field": "journal", "width": 8},
3: {"header": _("Account"), "field": "account", "width": 9},
4: {"header": _("Partner"), "field": "partner", "width": 25},
5: {"header": _("Ref - Label"), "field": "ref_label", "width": 40},
6: {"header": _("Due date"), "field": "due_date", "width": 11},
0: {"header": self.env._("Date"), "field": "date", "width": 11},
1: {"header": self.env._("Entry"), "field": "entry", "width": 18},
2: {"header": self.env._("Journal"), "field": "journal", "width": 8},
3: {"header": self.env._("Account"), "field": "account", "width": 9},
4: {"header": self.env._("Partner"), "field": "partner", "width": 25},
5: {"header": self.env._("Ref - Label"), "field": "ref_label", "width": 40},
6: {"header": self.env._("Due date"), "field": "due_date", "width": 11},
7: {
"header": _("Residual"),
"header": self.env._("Residual"),
"field": "residual",
"field_footer_total": "residual",
"field_final_balance": "residual",
"type": "amount",
"width": 14,
},
8: {
"header": _("Current"),
"header": self.env._("Current"),
"field": "current",
"field_footer_total": "current",
"field_footer_percent": "percent_current",
Expand All @@ -127,7 +127,7 @@ def _get_report_columns_with_move_line_details(self, report, column_index):
report_columns.update(

Check warning on line 127 in account_financial_report/report/aged_partner_balance_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance_xlsx.py#L127

Added line #L127 was not covered by tests
{
9: {
"header": _("Age ≤ 30 d."),
"header": self.env._("Age ≤ 30 d."),
"field": "30_days",
"field_footer_total": "30_days",
"field_footer_percent": "percent_30_days",
Expand All @@ -136,7 +136,7 @@ def _get_report_columns_with_move_line_details(self, report, column_index):
"width": 14,
},
10: {
"header": _("Age ≤ 60 d."),
"header": self.env._("Age ≤ 60 d."),
"field": "60_days",
"field_footer_total": "60_days",
"field_footer_percent": "percent_60_days",
Expand All @@ -145,7 +145,7 @@ def _get_report_columns_with_move_line_details(self, report, column_index):
"width": 14,
},
11: {
"header": _("Age ≤ 90 d."),
"header": self.env._("Age ≤ 90 d."),
"field": "90_days",
"field_footer_total": "90_days",
"field_footer_percent": "percent_90_days",
Expand All @@ -154,7 +154,7 @@ def _get_report_columns_with_move_line_details(self, report, column_index):
"width": 14,
},
12: {
"header": _("Age ≤ 120 d."),
"header": self.env._("Age ≤ 120 d."),
"field": "120_days",
"field_footer_total": "120_days",
"field_footer_percent": "percent_120_days",
Expand All @@ -163,7 +163,7 @@ def _get_report_columns_with_move_line_details(self, report, column_index):
"width": 14,
},
13: {
"header": _("Older"),
"header": self.env._("Older"),
"field": "older",
"field_footer_total": "older",
"field_footer_percent": "percent_older",
Expand Down Expand Up @@ -194,12 +194,12 @@ def _get_report_columns(self, report):

def _get_report_filters(self, report):
return [
[_("Date at filter"), report.date_at.strftime("%d/%m/%Y")],
[self.env._("Date at filter"), report.date_at.strftime("%d/%m/%Y")],
[
_("Target moves filter"),
_("All posted entries")
self.env._("Target moves filter"),
self.env._("All posted entries")
if report.target_move == "posted"
else _("All entries"),
else self.env._("All entries"),
],
]

Expand Down Expand Up @@ -321,7 +321,7 @@ def write_ending_balance_from_dict(self, my_object, report_data):
for Aged Partner Balance
"""
name = None
label = _("Partner cumul aged balance")
label = self.env._("Partner cumul aged balance")
return super().write_ending_balance_from_dict(

Check warning on line 325 in account_financial_report/report/aged_partner_balance_xlsx.py

View check run for this annotation

Codecov / codecov/patch

account_financial_report/report/aged_partner_balance_xlsx.py#L324-L325

Added lines #L324 - L325 were not covered by tests
my_object, name, label, report_data
)
Expand Down
20 changes: 13 additions & 7 deletions account_financial_report/report/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _get_account_type_domain(self, grouped_by):

def _get_acc_prt_accounts_ids(self, company_id, grouped_by):
accounts_domain = [
("company_id", "=", company_id),
("company_ids", "in", [company_id]),
] + self._get_account_type_domain(grouped_by)
acc_prt_accounts = self.env["account.account"].search(accounts_domain)
return acc_prt_accounts.ids
Expand All @@ -70,7 +70,7 @@ def _get_initial_balances_bs_ml_domain(
self, account_ids, company_id, date_from, base_domain, grouped_by, acc_prt=False
):
accounts_domain = [
("company_id", "=", company_id),
("company_ids", "in", [company_id]),
("include_initial_balance", "=", True),
]
if account_ids:
Expand All @@ -88,7 +88,7 @@ def _get_initial_balances_pl_ml_domain(
self, account_ids, company_id, date_from, fy_start_date, base_domain
):
accounts_domain = [
("company_id", "=", company_id),
("company_ids", "in", [company_id]),
("include_initial_balance", "=", False),
]
if account_ids:
Expand Down Expand Up @@ -118,7 +118,7 @@ def _get_initial_balance_fy_pl_ml_domain(
self, account_ids, company_id, fy_start_date, base_domain
):
accounts_domain = [
("company_id", "=", company_id),
("company_ids", "in", [company_id]),
("include_initial_balance", "=", False),
]
if account_ids:
Expand Down Expand Up @@ -155,7 +155,13 @@ def _get_pl_initial_balance(
return pl_initial_balance

def _get_gl_initial_acc(
self, account_ids, company_id, date_from, fy_start_date, base_domain, grouped_by
self,
account_ids,
company_id,
date_from,
fy_start_date,
base_domain,
grouped_by,
):
initial_domain_bs = self._get_initial_balances_bs_ml_domain(
account_ids, company_id, date_from, base_domain, grouped_by
Expand All @@ -182,7 +188,7 @@ def _prepare_gen_ld_data(self, gl_initial_acc, domain, grouped_by):
data[acc_id]["id"] = acc_id
if grouped_by:
data[acc_id][grouped_by] = False
method = "_prepare_gen_ld_data_group_%s" % grouped_by
method = f"_prepare_gen_ld_data_group_{grouped_by}"
if not hasattr(self, method):
return data
return getattr(self, method)(data, domain, grouped_by)
Expand Down Expand Up @@ -265,7 +271,7 @@ def _get_initial_balance_data(
unaffected_earnings_account = False
base_domain = []
if company_id:
base_domain += [("company_id", "=", company_id)]
base_domain += [("company_id", "in", [company_id])]
if partner_ids:
base_domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
Expand Down
4 changes: 2 additions & 2 deletions account_financial_report/report/general_ledger_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _generate_report_content(self, workbook, report, data, report_data):
)
else:
analytic_distribution += (
"%s " % analytic_data[int(account_id)]["name"]
f"{analytic_data[int(account_id)]['name']} "
)
line.update(
{
Expand Down Expand Up @@ -313,7 +313,7 @@ def _generate_report_content(self, workbook, report, data, report_data):
)
else:
analytic_distribution += (
"%s " % analytic_data[int(account_id)]["name"]
f"{analytic_data[int(account_id)]['name']} "
)
line.update(
{
Expand Down
Loading

0 comments on commit befa9ce

Please sign in to comment.