Skip to content

Commit b33173d

Browse files
committed
[18.0][MIG] l10n_it-financial_statements_report: Migration to 18.0
1 parent bea79eb commit b33173d

File tree

16 files changed

+254
-123
lines changed

16 files changed

+254
-123
lines changed

l10n_it_financial_statements_report/README.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ ITA - Stato patrimoniale e conto economico
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
20-
:target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_financial_statements_report
20+
:target: https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_financial_statements_report
2121
:alt: OCA/l10n-italy
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_financial_statements_report
23+
:target: https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-l10n_it_financial_statements_report
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -98,7 +98,7 @@ Bug Tracker
9898
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
9999
In case of trouble, please check there if your issue has already been reported.
100100
If you spotted it first, help us to smash it by providing a detailed and welcomed
101-
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_financial_statements_report%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
101+
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_financial_statements_report%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
102102

103103
Do not contact contributors directly about support or help with technical issues.
104104

@@ -113,22 +113,26 @@ Authors
113113
Contributors
114114
------------
115115

116-
- Silvio Gregorini <https://github.com/SilvioGregorini>
117-
- `Ooops <https://www.ooops404.com>`__
118-
- `TAKOBI <https://takobi.online>`__:
116+
- Silvio Gregorini <https://github.com/SilvioGregorini>
117+
- `Ooops <https://www.ooops404.com>`__
118+
- `TAKOBI <https://takobi.online>`__:
119119

120-
- Simone Rubino <sir@takobi.online>
120+
- Simone Rubino <sir@takobi.online>
121121

122-
- `Aion Tech <https://aiontech.company/>`__:
122+
- `Aion Tech <https://aiontech.company/>`__:
123123

124-
- Simone Rubino <simone.rubino@aion-tech.it>
124+
- Simone Rubino <simone.rubino@aion-tech.it>
125+
126+
- `Stesi Consulting <https://www.stesi.consulting>`__:
127+
128+
- Michele Di Croce <dicroce.m@stesi.consulting>
125129

126130
Other credits
127131
-------------
128132

129133
The development of this module has been financially supported by:
130134

131-
- Odoo Italia Network
135+
- Odoo Italia Network
132136

133137
Maintainers
134138
-----------
@@ -143,6 +147,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
143147
mission is to support the collaborative development of Odoo features and
144148
promote its widespread use.
145149

146-
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_financial_statements_report>`_ project on GitHub.
150+
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/18.0/l10n_it_financial_statements_report>`_ project on GitHub.
147151

148152
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

l10n_it_financial_statements_report/__manifest__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
# Copyright 2019 Alessandro Camilli (alessandrocamilli@openforce.it)
33
# Copyright 2019 Silvio Gregorini (silviogregorini@openforce.it)
44
# Copyright 2023 Simone Rubino - Aion Tech
5+
# Copyright 2025 Michele Di Croce - Stesi Consulting Srl
56
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
67

78
{
89
"name": "ITA - Stato patrimoniale e conto economico",
910
"summary": "Rendicontazione .pdf e .xls per stato patrimoniale e conto"
1011
" economico a sezioni contrapposte",
11-
"version": "16.0.1.0.5",
12+
"version": "18.0.1.0.0",
1213
"category": "Localization/Italy",
1314
"author": "Odoo Community Association (OCA), Openforce",
1415
"website": "https://github.com/OCA/l10n-italy"
@@ -23,10 +24,4 @@
2324
"report/reports.xml",
2425
"wizard/wizard_financial_statements_report.xml",
2526
],
26-
"assets": {
27-
"web.assets_backend": [
28-
"l10n_it_financial_statements_report/static/src/js/action_manager_report.js",
29-
"l10n_it_financial_statements_report/static/src/js/client_action.js",
30-
],
31-
},
3227
}
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
22

3-
from . import account_account
3+
from . import account_account, account_group

l10n_it_financial_statements_report/models/account_account.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,34 @@
3636
"equity",
3737
],
3838
}
39+
ACCOUNT_TYPES_NEGATIVE_SIGN = [
40+
"equity_unaffected",
41+
"equity",
42+
"income",
43+
"income_other",
44+
"liability_payable",
45+
"liability_credit_card",
46+
"asset_prepayments",
47+
"liability_current",
48+
"liability_non_current",
49+
]
3950

4051

4152
class Account(models.Model):
4253
_inherit = "account.account"
4354

55+
account_balance_sign = fields.Integer(
56+
string="Balance sign", compute="_compute_account_balance_sign"
57+
)
58+
59+
@api.depends("account_type")
60+
def _compute_account_balance_sign(self):
61+
for account in self:
62+
if account.account_type in ACCOUNT_TYPES_NEGATIVE_SIGN:
63+
account.account_balance_sign = -1
64+
else:
65+
account.account_balance_sign = 1
66+
4467
# This field is almost equal to `internal_group`; yet, we wanna keep the
4568
# report independent from Odoo's accounting workflow, so we'll use this
4669
# new field for the report
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
from odoo import fields, models
2+
from odoo.tools import SQL
3+
4+
5+
class AccountGroup(models.Model):
6+
_inherit = "account.group"
7+
account_balance_sign = fields.Integer(
8+
compute="_compute_account_balance_sign",
9+
string="Balance sign",
10+
)
11+
current_account_ids = fields.One2many(
12+
"account.account", compute="_compute_current_account_ids"
13+
)
14+
15+
def _compute_current_account_ids(self):
16+
"""Retrieves every account from `self` and `self`'s subgroups.
17+
In Odoo 18 the group_id on account is not stored so it raises
18+
an error the one2many account_ids with inverse name group_id."""
19+
group_ids = self.ids
20+
self.current_account_ids = self.env["account.account"]
21+
if not group_ids:
22+
return
23+
group_ids = SQL(",".join(map(str, group_ids)))
24+
results = self.env.execute_query(
25+
SQL(
26+
"""
27+
SELECT
28+
agroup.id AS group_id,
29+
STRING_AGG(DISTINCT account.id::text, ', ') as account_ids
30+
FROM account_group agroup
31+
left join account_account account
32+
ON agroup.code_prefix_start <= LEFT(%(code_store)s->>%(root_company_id)s,
33+
char_length(agroup.code_prefix_start))
34+
AND agroup.code_prefix_end >= LEFT(%(code_store)s->>%(root_company_id)s,
35+
char_length(agroup.code_prefix_end))
36+
AND agroup.company_id = %(root_company_id)s
37+
AND agroup.id IN (%(group_ids)s)
38+
GROUP BY group_id
39+
""",
40+
code_store=SQL.identifier("account", "code_store"),
41+
group_ids=group_ids,
42+
root_company_id=str(self.env.company.root_id.id),
43+
)
44+
)
45+
group_by_code = dict(results)
46+
self.current_account_ids = self.env["account.account"]
47+
if not group_by_code:
48+
return
49+
for record in self:
50+
record.current_account_ids = list(
51+
map(int, group_by_code.get(record.id, "").split(", "))
52+
)
53+
54+
def _compute_account_balance_sign(self):
55+
for group in self:
56+
group.account_balance_sign = group.get_account_balance_sign()
57+
58+
def get_account_balance_sign(self):
59+
self.ensure_one()
60+
progenitor = self.get_group_progenitor()
61+
accounts = progenitor.get_group_accounts()
62+
if accounts:
63+
return accounts[0].account_balance_sign
64+
return 1
65+
66+
def get_group_accounts(self):
67+
"""Retrieves every account from `self` and `self`'s subgroups."""
68+
return (self + self.get_group_subgroups()).mapped("current_account_ids")
69+
70+
def get_group_progenitor(self):
71+
self.ensure_one()
72+
if not self.parent_id:
73+
return self
74+
return self.get_group_parents().filtered(lambda g: not g.parent_id)
75+
76+
def get_group_parents(self):
77+
"""
78+
Retrieves every parent for group `self`.
79+
:return: group's parents as recordset, or empty recordset if `self`
80+
has no parents. If a recursion is found, an error is raised.
81+
"""
82+
self.ensure_one()
83+
parent_ids = []
84+
parent = self.parent_id
85+
while parent:
86+
parent_ids.append(parent.id)
87+
parent = parent.parent_id
88+
return self.browse(parent_ids)
89+
90+
def get_group_subgroups(self):
91+
"""Retrieves every subgroup for groups `self`."""
92+
subgroups_ids = self.search([("id", "child_of", self.ids)])
93+
return subgroups_ids

l10n_it_financial_statements_report/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
- Simone Rubino \<<sir@takobi.online>\>
55
- [Aion Tech](https://aiontech.company/):
66
- Simone Rubino \<<simone.rubino@aion-tech.it>\>
7+
- [Stesi Consulting](https://www.stesi.consulting):
8+
- Michele Di Croce \<<dicroce.m@stesi.consulting>\>

l10n_it_financial_statements_report/report/financial_statements_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ def get_column_data(self):
212212

213213
def get_report_section(self, account=None, group=None):
214214
section = ""
215-
if not account and group and group.account_ids:
216-
account = group.account_ids[0]
215+
if not account and group and group.current_account_ids:
216+
account = group.current_account_ids[0]
217217
if account:
218218
section = account.financial_statements_report_section
219219
return section

l10n_it_financial_statements_report/report/financial_statements_report_xlsx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,9 @@ def format_value_by_lang(self, lang, value=None, decimals=None):
598598
"""Mimics `res.lang` model's `format` method"""
599599
percent = f"%.{decimals or 2}f"
600600
value = value or 0
601-
return lang.format(percent, value, grouping=True, monetary=True)
601+
602+
lang = self.env["res.lang"].sudo().browse(lang.get("id"))
603+
return lang.format(percent, value, grouping=True)
602604

603605
def get_indent_data(self, line=None, col_dict=None):
604606
return col_dict.get("indent_field"), col_dict.get("indent_unit")

l10n_it_financial_statements_report/report/templates/financial_statements_report.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<t t-call="web.external_layout">
2020
<t t-set="company" t-value="o.company_id" />
2121
<link
22-
href="/account_financial_report/static/src/css/report.css"
22+
href="/l10n_it_financial_statements_report/static/src/css/report.css"
2323
rel="stylesheet"
2424
/>
2525
<t

0 commit comments

Comments
 (0)