odoo-addon-account-financial-report 15.0.1.1.0.1__py3-none-any.whl → 18.0.1.4.4.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/account_financial_report/README.rst +131 -74
- odoo/addons/account_financial_report/__manifest__.py +6 -9
- odoo/addons/account_financial_report/i18n/account_financial_report.pot +313 -188
- odoo/addons/account_financial_report/i18n/ar.po +579 -433
- odoo/addons/account_financial_report/i18n/ca.po +474 -289
- odoo/addons/account_financial_report/i18n/{fr_FR.po → ca_AD.po} +539 -491
- odoo/addons/account_financial_report/i18n/ca_ES.po +1891 -0
- odoo/addons/account_financial_report/i18n/de.po +455 -295
- odoo/addons/account_financial_report/i18n/es.po +458 -394
- odoo/addons/account_financial_report/i18n/es_AR.po +464 -283
- odoo/addons/account_financial_report/i18n/es_MX.po +315 -220
- odoo/addons/account_financial_report/i18n/fr.po +620 -435
- odoo/addons/account_financial_report/i18n/fr_CH.po +616 -462
- odoo/addons/account_financial_report/i18n/hr.po +506 -355
- odoo/addons/account_financial_report/i18n/hr_HR.po +331 -232
- odoo/addons/account_financial_report/i18n/it.po +538 -356
- odoo/addons/account_financial_report/i18n/ja.po +339 -240
- odoo/addons/account_financial_report/i18n/nl.po +462 -324
- odoo/addons/account_financial_report/i18n/nl_NL.po +318 -220
- odoo/addons/account_financial_report/i18n/pt.po +429 -242
- odoo/addons/account_financial_report/i18n/pt_BR.po +588 -438
- odoo/addons/account_financial_report/i18n/ro.po +499 -342
- odoo/addons/account_financial_report/i18n/sl.po +1945 -0
- odoo/addons/account_financial_report/i18n/sv.po +1997 -0
- odoo/addons/account_financial_report/i18n/tr.po +1947 -0
- odoo/addons/account_financial_report/menuitems.xml +1 -1
- odoo/addons/account_financial_report/models/__init__.py +2 -0
- odoo/addons/account_financial_report/models/account_age_report_configuration.py +49 -0
- odoo/addons/account_financial_report/models/account_group.py +62 -23
- odoo/addons/account_financial_report/models/account_move_line.py +33 -3
- odoo/addons/account_financial_report/models/ir_actions_report.py +6 -4
- odoo/addons/account_financial_report/models/res_config_settings.py +36 -0
- odoo/addons/account_financial_report/readme/CONFIGURE.md +26 -0
- odoo/addons/account_financial_report/readme/CONTRIBUTORS.md +38 -0
- odoo/addons/account_financial_report/readme/CREDITS.md +1 -0
- odoo/addons/account_financial_report/readme/DESCRIPTION.md +21 -0
- odoo/addons/account_financial_report/readme/HISTORY.md +16 -0
- odoo/addons/account_financial_report/readme/ROADMAP.md +6 -0
- odoo/addons/account_financial_report/report/abstract_report.py +73 -23
- odoo/addons/account_financial_report/report/abstract_report_xlsx.py +28 -23
- odoo/addons/account_financial_report/report/aged_partner_balance.py +131 -30
- odoo/addons/account_financial_report/report/aged_partner_balance_xlsx.py +158 -118
- odoo/addons/account_financial_report/report/general_ledger.py +421 -340
- odoo/addons/account_financial_report/report/general_ledger_xlsx.py +127 -75
- odoo/addons/account_financial_report/report/journal_ledger.py +84 -68
- odoo/addons/account_financial_report/report/journal_ledger_xlsx.py +14 -8
- odoo/addons/account_financial_report/report/open_items.py +113 -70
- odoo/addons/account_financial_report/report/open_items_xlsx.py +152 -19
- odoo/addons/account_financial_report/report/templates/aged_partner_balance.xml +408 -311
- odoo/addons/account_financial_report/report/templates/general_ledger.xml +273 -213
- odoo/addons/account_financial_report/report/templates/journal_ledger.xml +70 -76
- odoo/addons/account_financial_report/report/templates/layouts.xml +12 -1
- odoo/addons/account_financial_report/report/templates/open_items.xml +181 -55
- odoo/addons/account_financial_report/report/templates/trial_balance.xml +304 -195
- odoo/addons/account_financial_report/report/templates/vat_report.xml +10 -10
- odoo/addons/account_financial_report/report/trial_balance.py +463 -211
- odoo/addons/account_financial_report/report/trial_balance_xlsx.py +37 -38
- odoo/addons/account_financial_report/report/vat_report.py +36 -25
- odoo/addons/account_financial_report/report/vat_report_xlsx.py +1 -1
- odoo/addons/account_financial_report/security/ir.model.access.csv +2 -0
- odoo/addons/account_financial_report/security/security.xml +8 -0
- odoo/addons/account_financial_report/static/description/index.html +106 -55
- odoo/addons/account_financial_report/static/src/css/report.css +77 -42
- odoo/addons/account_financial_report/static/src/css/report_html.css +10 -0
- odoo/addons/account_financial_report/static/src/js/report.esm.js +72 -0
- odoo/addons/account_financial_report/static/src/js/report_action.esm.js +39 -0
- odoo/addons/account_financial_report/static/src/xml/report.xml +10 -9
- odoo/addons/account_financial_report/tests/__init__.py +1 -0
- odoo/addons/account_financial_report/tests/test_age_report_configuration.py +42 -0
- odoo/addons/account_financial_report/tests/test_aged_partner_balance.py +99 -9
- odoo/addons/account_financial_report/tests/test_general_ledger.py +19 -9
- odoo/addons/account_financial_report/tests/test_journal_ledger.py +18 -9
- odoo/addons/account_financial_report/tests/test_open_items.py +42 -2
- odoo/addons/account_financial_report/tests/test_trial_balance.py +114 -223
- odoo/addons/account_financial_report/tests/test_vat_report.py +17 -9
- odoo/addons/account_financial_report/view/account_age_report_configuration_views.xml +41 -0
- odoo/addons/account_financial_report/view/res_config_settings_views.xml +51 -0
- odoo/addons/account_financial_report/wizard/abstract_wizard.py +23 -0
- odoo/addons/account_financial_report/wizard/aged_partner_balance_wizard.py +22 -8
- odoo/addons/account_financial_report/wizard/aged_partner_balance_wizard_view.xml +2 -3
- odoo/addons/account_financial_report/wizard/general_ledger_wizard.py +42 -36
- odoo/addons/account_financial_report/wizard/general_ledger_wizard_view.xml +26 -41
- odoo/addons/account_financial_report/wizard/journal_ledger_wizard.py +19 -7
- odoo/addons/account_financial_report/wizard/journal_ledger_wizard_view.xml +15 -14
- odoo/addons/account_financial_report/wizard/open_items_wizard.py +34 -8
- odoo/addons/account_financial_report/wizard/open_items_wizard_view.xml +16 -14
- odoo/addons/account_financial_report/wizard/trial_balance_wizard.py +68 -45
- odoo/addons/account_financial_report/wizard/trial_balance_wizard_view.xml +40 -39
- odoo/addons/account_financial_report/wizard/vat_report_wizard.py +9 -3
- odoo/addons/account_financial_report/wizard/vat_report_wizard_view.xml +14 -14
- odoo_addon_account_financial_report-18.0.1.4.4.3.dist-info/METADATA +234 -0
- odoo_addon_account_financial_report-18.0.1.4.4.3.dist-info/RECORD +107 -0
- {odoo_addon_account_financial_report-15.0.1.1.0.1.dist-info → odoo_addon_account_financial_report-18.0.1.4.4.3.dist-info}/WHEEL +1 -1
- odoo_addon_account_financial_report-18.0.1.4.4.3.dist-info/top_level.txt +1 -0
- odoo/addons/account_financial_report/readme/CONTRIBUTORS.rst +0 -35
- odoo/addons/account_financial_report/readme/DESCRIPTION.rst +0 -16
- odoo/addons/account_financial_report/readme/HISTORY.rst +0 -19
- odoo/addons/account_financial_report/readme/ROADMAP.rst +0 -7
- odoo/addons/account_financial_report/static/src/js/action_manager_report.js +0 -37
- odoo/addons/account_financial_report/static/src/js/client_action.js +0 -58
- odoo/addons/account_financial_report/static/src/js/report.js +0 -58
- odoo_addon_account_financial_report-15.0.1.1.0.1.dist-info/METADATA +0 -179
- odoo_addon_account_financial_report-15.0.1.1.0.1.dist-info/RECORD +0 -95
- odoo_addon_account_financial_report-15.0.1.1.0.1.dist-info/top_level.txt +0 -1
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
from odoo import api, models
|
|
7
|
+
from odoo import _, api, models
|
|
8
|
+
from odoo.exceptions import UserError
|
|
9
|
+
from odoo.tools.float_utils import float_is_zero
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
class TrialBalanceReport(models.AbstractModel):
|
|
@@ -23,13 +25,17 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
23
25
|
show_partner_details,
|
|
24
26
|
):
|
|
25
27
|
accounts_domain = [
|
|
26
|
-
("
|
|
27
|
-
("
|
|
28
|
+
("company_ids", "in", [company_id]),
|
|
29
|
+
("include_initial_balance", "=", True),
|
|
28
30
|
]
|
|
29
31
|
if account_ids:
|
|
30
32
|
accounts_domain += [("id", "in", account_ids)]
|
|
31
33
|
domain = [("date", "<", date_from)]
|
|
32
|
-
accounts =
|
|
34
|
+
accounts = (
|
|
35
|
+
self.env["account.account"]
|
|
36
|
+
.with_context(active_test=False)
|
|
37
|
+
.search(accounts_domain)
|
|
38
|
+
)
|
|
33
39
|
domain += [("account_id", "in", accounts.ids)]
|
|
34
40
|
if company_id:
|
|
35
41
|
domain += [("company_id", "=", company_id)]
|
|
@@ -42,7 +48,13 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
42
48
|
else:
|
|
43
49
|
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
44
50
|
if show_partner_details:
|
|
45
|
-
domain += [
|
|
51
|
+
domain += [
|
|
52
|
+
(
|
|
53
|
+
"account_id.account_type",
|
|
54
|
+
"in",
|
|
55
|
+
["asset_receivable", "liability_payable"],
|
|
56
|
+
)
|
|
57
|
+
]
|
|
46
58
|
return domain
|
|
47
59
|
|
|
48
60
|
def _get_initial_balances_pl_ml_domain(
|
|
@@ -57,13 +69,17 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
57
69
|
fy_start_date,
|
|
58
70
|
):
|
|
59
71
|
accounts_domain = [
|
|
60
|
-
("
|
|
61
|
-
("
|
|
72
|
+
("company_ids", "in", [company_id]),
|
|
73
|
+
("include_initial_balance", "=", False),
|
|
62
74
|
]
|
|
63
75
|
if account_ids:
|
|
64
76
|
accounts_domain += [("id", "in", account_ids)]
|
|
65
77
|
domain = [("date", "<", date_from), ("date", ">=", fy_start_date)]
|
|
66
|
-
accounts =
|
|
78
|
+
accounts = (
|
|
79
|
+
self.env["account.account"]
|
|
80
|
+
.with_context(active_test=False)
|
|
81
|
+
.search(accounts_domain)
|
|
82
|
+
)
|
|
67
83
|
domain += [("account_id", "in", accounts.ids)]
|
|
68
84
|
if company_id:
|
|
69
85
|
domain += [("company_id", "=", company_id)]
|
|
@@ -76,7 +92,13 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
76
92
|
else:
|
|
77
93
|
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
78
94
|
if show_partner_details:
|
|
79
|
-
domain += [
|
|
95
|
+
domain += [
|
|
96
|
+
(
|
|
97
|
+
"account_id.account_type",
|
|
98
|
+
"in",
|
|
99
|
+
["asset_receivable", "liability_payable"],
|
|
100
|
+
)
|
|
101
|
+
]
|
|
80
102
|
return domain
|
|
81
103
|
|
|
82
104
|
@api.model
|
|
@@ -92,7 +114,7 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
92
114
|
show_partner_details,
|
|
93
115
|
):
|
|
94
116
|
domain = [
|
|
95
|
-
("display_type", "
|
|
117
|
+
("display_type", "not in", ["line_note", "line_section"]),
|
|
96
118
|
("date", ">=", date_from),
|
|
97
119
|
("date", "<=", date_to),
|
|
98
120
|
]
|
|
@@ -109,7 +131,13 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
109
131
|
else:
|
|
110
132
|
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
111
133
|
if show_partner_details:
|
|
112
|
-
domain += [
|
|
134
|
+
domain += [
|
|
135
|
+
(
|
|
136
|
+
"account_id.account_type",
|
|
137
|
+
"in",
|
|
138
|
+
["asset_receivable", "liability_payable"],
|
|
139
|
+
)
|
|
140
|
+
]
|
|
113
141
|
return domain
|
|
114
142
|
|
|
115
143
|
def _get_initial_balance_fy_pl_ml_domain(
|
|
@@ -123,13 +151,17 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
123
151
|
show_partner_details,
|
|
124
152
|
):
|
|
125
153
|
accounts_domain = [
|
|
126
|
-
("
|
|
127
|
-
("
|
|
154
|
+
("company_ids", "in", [company_id]),
|
|
155
|
+
("include_initial_balance", "=", False),
|
|
128
156
|
]
|
|
129
157
|
if account_ids:
|
|
130
158
|
accounts_domain += [("id", "in", account_ids)]
|
|
131
159
|
domain = [("date", "<", fy_start_date)]
|
|
132
|
-
accounts =
|
|
160
|
+
accounts = (
|
|
161
|
+
self.env["account.account"]
|
|
162
|
+
.with_context(active_test=False)
|
|
163
|
+
.search(accounts_domain)
|
|
164
|
+
)
|
|
133
165
|
domain += [("account_id", "in", accounts.ids)]
|
|
134
166
|
if company_id:
|
|
135
167
|
domain += [("company_id", "=", company_id)]
|
|
@@ -142,7 +174,13 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
142
174
|
else:
|
|
143
175
|
domain += [("move_id.state", "in", ["posted", "draft"])]
|
|
144
176
|
if show_partner_details:
|
|
145
|
-
domain += [
|
|
177
|
+
domain += [
|
|
178
|
+
(
|
|
179
|
+
"account_id.account_type",
|
|
180
|
+
"in",
|
|
181
|
+
["asset_receivable", "liability_payable"],
|
|
182
|
+
)
|
|
183
|
+
]
|
|
146
184
|
return domain
|
|
147
185
|
|
|
148
186
|
def _get_pl_initial_balance(
|
|
@@ -167,8 +205,8 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
167
205
|
)
|
|
168
206
|
initial_balances = self.env["account.move.line"].read_group(
|
|
169
207
|
domain=domain,
|
|
170
|
-
fields=["account_id", "balance", "amount_currency"],
|
|
171
|
-
groupby=["account_id"],
|
|
208
|
+
fields=["account_id", "balance", "amount_currency:sum"],
|
|
209
|
+
groupby=["account_id", "currency_id"],
|
|
172
210
|
)
|
|
173
211
|
pl_initial_balance = 0.0
|
|
174
212
|
pl_initial_currency_balance = 0.0
|
|
@@ -186,33 +224,46 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
186
224
|
):
|
|
187
225
|
for tb in tb_period_acc:
|
|
188
226
|
acc_id = tb["account_id"][0]
|
|
189
|
-
total_amount[acc_id] =
|
|
227
|
+
total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency)
|
|
190
228
|
total_amount[acc_id]["credit"] = tb["credit"]
|
|
191
229
|
total_amount[acc_id]["debit"] = tb["debit"]
|
|
192
230
|
total_amount[acc_id]["balance"] = tb["balance"]
|
|
193
231
|
total_amount[acc_id]["initial_balance"] = 0.0
|
|
194
|
-
total_amount[acc_id]["ending_balance"] = tb["balance"]
|
|
195
232
|
if foreign_currency:
|
|
196
233
|
total_amount[acc_id]["initial_currency_balance"] = 0.0
|
|
197
|
-
|
|
198
|
-
|
|
234
|
+
if "__context" in tb and "group_by" in tb["__context"]:
|
|
235
|
+
group_by = tb["__context"]["group_by"][0]
|
|
236
|
+
gb_data = {}
|
|
237
|
+
tb_grouped = self.env["account.move.line"].read_group(
|
|
238
|
+
domain=tb["__domain"],
|
|
239
|
+
fields=[
|
|
240
|
+
group_by,
|
|
241
|
+
"debit",
|
|
242
|
+
"credit",
|
|
243
|
+
"balance",
|
|
244
|
+
"amount_currency:sum",
|
|
245
|
+
],
|
|
246
|
+
groupby=[group_by],
|
|
199
247
|
)
|
|
248
|
+
for tb2 in tb_grouped:
|
|
249
|
+
gb_id = tb2[group_by][0] if tb2[group_by] else 0
|
|
250
|
+
gb_data[gb_id] = self._prepare_total_amount(tb2, foreign_currency)
|
|
251
|
+
gb_data[gb_id]["credit"] = tb2["credit"]
|
|
252
|
+
gb_data[gb_id]["debit"] = tb2["debit"]
|
|
253
|
+
gb_data[gb_id]["balance"] = tb2["balance"]
|
|
254
|
+
gb_data[gb_id]["initial_balance"] = 0.0
|
|
255
|
+
if foreign_currency:
|
|
256
|
+
gb_data[gb_id]["initial_currency_balance"] = 0.0
|
|
257
|
+
total_amount[acc_id]["group_by"] = group_by
|
|
258
|
+
total_amount[acc_id]["group_by_data"] = gb_data
|
|
200
259
|
for tb in tb_initial_acc:
|
|
201
260
|
acc_id = tb["account_id"]
|
|
202
261
|
if acc_id not in total_amount.keys():
|
|
203
|
-
total_amount[acc_id] =
|
|
204
|
-
total_amount[acc_id]["
|
|
205
|
-
total_amount[acc_id]["
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
total_amount[acc_id]["ending_balance"] = tb["balance"]
|
|
209
|
-
if foreign_currency:
|
|
210
|
-
total_amount[acc_id]["initial_currency_balance"] = round(
|
|
211
|
-
tb["amount_currency"], 2
|
|
212
|
-
)
|
|
213
|
-
total_amount[acc_id]["ending_currency_balance"] = round(
|
|
214
|
-
tb["amount_currency"], 2
|
|
215
|
-
)
|
|
262
|
+
total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency)
|
|
263
|
+
total_amount[acc_id]["group_by_data"] = {}
|
|
264
|
+
total_amount[acc_id]["group_by_data"][0] = self._prepare_total_amount(
|
|
265
|
+
tb, foreign_currency
|
|
266
|
+
)
|
|
216
267
|
else:
|
|
217
268
|
total_amount[acc_id]["initial_balance"] = tb["balance"]
|
|
218
269
|
total_amount[acc_id]["ending_balance"] += tb["balance"]
|
|
@@ -223,25 +274,69 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
223
274
|
total_amount[acc_id]["ending_currency_balance"] += round(
|
|
224
275
|
tb["amount_currency"], 2
|
|
225
276
|
)
|
|
277
|
+
if "group_by_data" in tb:
|
|
278
|
+
for gb_key in list(tb["group_by_data"]):
|
|
279
|
+
tb2 = tb["group_by_data"][gb_key]
|
|
280
|
+
if "group_by_data" in total_amount[acc_id]:
|
|
281
|
+
if gb_key not in total_amount[acc_id]["group_by_data"]:
|
|
282
|
+
total_amount[acc_id]["group_by_data"][gb_key] = (
|
|
283
|
+
self._prepare_total_amount(tb2, foreign_currency)
|
|
284
|
+
)
|
|
285
|
+
else:
|
|
286
|
+
total_amount[acc_id]["group_by_data"][gb_key][
|
|
287
|
+
"initial_balance"
|
|
288
|
+
] = tb2["balance"]
|
|
289
|
+
total_amount[acc_id]["group_by_data"][gb_key][
|
|
290
|
+
"ending_balance"
|
|
291
|
+
] += tb2["balance"]
|
|
292
|
+
if foreign_currency:
|
|
293
|
+
total_amount[acc_id]["group_by_data"][gb_key][
|
|
294
|
+
"initial_currency_balance"
|
|
295
|
+
] = round(tb2["amount_currency"], 2)
|
|
296
|
+
total_amount[acc_id]["group_by_data"][gb_key][
|
|
297
|
+
"ending_currency_balance"
|
|
298
|
+
] += round(tb2["amount_currency"], 2)
|
|
226
299
|
return total_amount
|
|
227
300
|
|
|
301
|
+
@api.model
|
|
302
|
+
def _prepare_total_amount(self, tb, foreign_currency):
|
|
303
|
+
res = {
|
|
304
|
+
"credit": 0.0,
|
|
305
|
+
"debit": 0.0,
|
|
306
|
+
"balance": 0.0,
|
|
307
|
+
"initial_balance": tb["balance"],
|
|
308
|
+
"ending_balance": tb["balance"],
|
|
309
|
+
}
|
|
310
|
+
if foreign_currency:
|
|
311
|
+
res["initial_currency_balance"] = round(tb["amount_currency"], 2)
|
|
312
|
+
res["ending_currency_balance"] = round(tb["amount_currency"], 2)
|
|
313
|
+
return res
|
|
314
|
+
|
|
228
315
|
@api.model
|
|
229
316
|
def _compute_acc_prt_amount(
|
|
230
317
|
self, total_amount, tb, acc_id, prt_id, foreign_currency
|
|
231
318
|
):
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
total_amount[acc_id]
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if foreign_currency:
|
|
239
|
-
total_amount[acc_id][prt_id]["initial_currency_balance"] = round(
|
|
240
|
-
tb["amount_currency"], 2
|
|
241
|
-
)
|
|
242
|
-
total_amount[acc_id][prt_id]["ending_currency_balance"] = round(
|
|
243
|
-
tb["amount_currency"], 2
|
|
319
|
+
# Add keys to dict if not exists
|
|
320
|
+
if acc_id not in total_amount:
|
|
321
|
+
total_amount[acc_id] = self._prepare_total_amount(tb, foreign_currency)
|
|
322
|
+
if prt_id not in total_amount[acc_id]:
|
|
323
|
+
total_amount[acc_id][prt_id] = self._prepare_total_amount(
|
|
324
|
+
tb, foreign_currency
|
|
244
325
|
)
|
|
326
|
+
else:
|
|
327
|
+
# Increase balance field values
|
|
328
|
+
total_amount[acc_id][prt_id]["initial_balance"] = tb["balance"]
|
|
329
|
+
total_amount[acc_id][prt_id]["ending_balance"] += tb["balance"]
|
|
330
|
+
if foreign_currency:
|
|
331
|
+
total_amount[acc_id][prt_id]["initial_currency_balance"] = round(
|
|
332
|
+
tb["amount_currency"], 2
|
|
333
|
+
)
|
|
334
|
+
total_amount[acc_id][prt_id]["ending_currency_balance"] += round(
|
|
335
|
+
tb["amount_currency"], 2
|
|
336
|
+
)
|
|
337
|
+
total_amount[acc_id][prt_id]["partner_name"] = (
|
|
338
|
+
tb["partner_id"][1] if tb["partner_id"] else _("Missing Partner")
|
|
339
|
+
)
|
|
245
340
|
return total_amount
|
|
246
341
|
|
|
247
342
|
@api.model
|
|
@@ -252,54 +347,74 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
252
347
|
partners_data = {}
|
|
253
348
|
for tb in tb_period_prt:
|
|
254
349
|
acc_id = tb["account_id"][0]
|
|
255
|
-
if tb["partner_id"]
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
tb["amount_currency"], 2
|
|
271
|
-
)
|
|
272
|
-
partners_ids.add(tb["partner_id"])
|
|
350
|
+
prt_id = tb["partner_id"][0] if tb["partner_id"] else 0
|
|
351
|
+
if prt_id not in partners_ids:
|
|
352
|
+
partner_name = (
|
|
353
|
+
tb["partner_id"][1] if tb["partner_id"] else _("Missing Partner")
|
|
354
|
+
)
|
|
355
|
+
partners_data.update({prt_id: {"id": prt_id, "name": partner_name}})
|
|
356
|
+
total_amount[acc_id][prt_id] = self._prepare_total_amount(
|
|
357
|
+
tb, foreign_currency
|
|
358
|
+
)
|
|
359
|
+
total_amount[acc_id][prt_id]["credit"] = tb["credit"]
|
|
360
|
+
total_amount[acc_id][prt_id]["debit"] = tb["debit"]
|
|
361
|
+
total_amount[acc_id][prt_id]["balance"] = tb["balance"]
|
|
362
|
+
total_amount[acc_id][prt_id]["initial_balance"] = 0.0
|
|
363
|
+
total_amount[acc_id][prt_id]["partner_name"] = partners_data[prt_id]["name"]
|
|
364
|
+
partners_ids.add(prt_id)
|
|
273
365
|
for tb in tb_initial_prt:
|
|
274
366
|
acc_id = tb["account_id"][0]
|
|
275
|
-
if tb["partner_id"]
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
"initial_currency_balance"
|
|
297
|
-
] += round(tb["amount_currency"], 2)
|
|
298
|
-
total_amount[acc_id][prt_id][
|
|
299
|
-
"ending_currency_balance"
|
|
300
|
-
] += round(tb["amount_currency"], 2)
|
|
367
|
+
prt_id = tb["partner_id"][0] if tb["partner_id"] else 0
|
|
368
|
+
if prt_id not in partners_ids:
|
|
369
|
+
partner_name = (
|
|
370
|
+
tb["partner_id"][1] if tb["partner_id"] else _("Missing Partner")
|
|
371
|
+
)
|
|
372
|
+
partners_data.update({prt_id: {"id": prt_id, "name": partner_name}})
|
|
373
|
+
total_amount = self._compute_acc_prt_amount(
|
|
374
|
+
total_amount, tb, acc_id, prt_id, foreign_currency
|
|
375
|
+
)
|
|
376
|
+
# sort on partner_name
|
|
377
|
+
for acc_id, total_data in total_amount.items():
|
|
378
|
+
tmp_list = sorted(
|
|
379
|
+
total_data.items(),
|
|
380
|
+
key=lambda x: isinstance(x[0], int)
|
|
381
|
+
and isinstance(x[1], dict)
|
|
382
|
+
and x[1]["partner_name"]
|
|
383
|
+
or x[0],
|
|
384
|
+
)
|
|
385
|
+
total_amount[acc_id] = {}
|
|
386
|
+
for key, value in tmp_list:
|
|
387
|
+
total_amount[acc_id][key] = value
|
|
301
388
|
return total_amount, partners_data
|
|
302
389
|
|
|
390
|
+
def _remove_accounts_at_cero(self, total_amount, show_partner_details, company):
|
|
391
|
+
def is_removable(d):
|
|
392
|
+
rounding = company.currency_id.rounding
|
|
393
|
+
return (
|
|
394
|
+
float_is_zero(d["initial_balance"], precision_rounding=rounding)
|
|
395
|
+
and float_is_zero(d["credit"], precision_rounding=rounding)
|
|
396
|
+
and float_is_zero(d["debit"], precision_rounding=rounding)
|
|
397
|
+
and float_is_zero(d["ending_balance"], precision_rounding=rounding)
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
accounts_to_remove = []
|
|
401
|
+
for acc_id, ta_data in total_amount.items():
|
|
402
|
+
if is_removable(ta_data):
|
|
403
|
+
accounts_to_remove.append(acc_id)
|
|
404
|
+
elif show_partner_details:
|
|
405
|
+
partner_to_remove = []
|
|
406
|
+
for key, value in ta_data.items():
|
|
407
|
+
# If the show_partner_details option is checked,
|
|
408
|
+
# the partner data is in the same account data dict
|
|
409
|
+
# but with the partner id as the key
|
|
410
|
+
if isinstance(key, int) and is_removable(value):
|
|
411
|
+
partner_to_remove.append(key)
|
|
412
|
+
for partner_id in partner_to_remove:
|
|
413
|
+
del ta_data[partner_id]
|
|
414
|
+
for account_id in accounts_to_remove:
|
|
415
|
+
del total_amount[account_id]
|
|
416
|
+
|
|
417
|
+
# flake8: noqa: C901
|
|
303
418
|
@api.model
|
|
304
419
|
def _get_data(
|
|
305
420
|
self,
|
|
@@ -315,19 +430,27 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
315
430
|
hide_account_at_0,
|
|
316
431
|
unaffected_earnings_account,
|
|
317
432
|
fy_start_date,
|
|
433
|
+
grouped_by,
|
|
318
434
|
):
|
|
319
|
-
accounts_domain = [("
|
|
435
|
+
accounts_domain = [("company_ids", "in", [company_id])]
|
|
320
436
|
if account_ids:
|
|
321
437
|
accounts_domain += [("id", "in", account_ids)]
|
|
322
438
|
# If explicit list of accounts is provided,
|
|
323
439
|
# don't include unaffected earnings account
|
|
324
440
|
unaffected_earnings_account = False
|
|
325
|
-
accounts =
|
|
441
|
+
accounts = (
|
|
442
|
+
self.env["account.account"]
|
|
443
|
+
.with_context(active_test=False)
|
|
444
|
+
.search(accounts_domain)
|
|
445
|
+
)
|
|
326
446
|
tb_initial_acc = []
|
|
327
447
|
for account in accounts:
|
|
328
448
|
tb_initial_acc.append(
|
|
329
449
|
{"account_id": account.id, "balance": 0.0, "amount_currency": 0.0}
|
|
330
450
|
)
|
|
451
|
+
groupby_fields = ["account_id", "currency_id"]
|
|
452
|
+
if grouped_by:
|
|
453
|
+
groupby_fields.append("analytic_account_ids")
|
|
331
454
|
initial_domain_bs = self._get_initial_balances_bs_ml_domain(
|
|
332
455
|
account_ids,
|
|
333
456
|
journal_ids,
|
|
@@ -339,8 +462,8 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
339
462
|
)
|
|
340
463
|
tb_initial_acc_bs = self.env["account.move.line"].read_group(
|
|
341
464
|
domain=initial_domain_bs,
|
|
342
|
-
fields=["account_id", "balance", "amount_currency"],
|
|
343
|
-
groupby=
|
|
465
|
+
fields=["account_id", "balance", "amount_currency:sum"],
|
|
466
|
+
groupby=groupby_fields,
|
|
344
467
|
)
|
|
345
468
|
initial_domain_pl = self._get_initial_balances_pl_ml_domain(
|
|
346
469
|
account_ids,
|
|
@@ -354,8 +477,8 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
354
477
|
)
|
|
355
478
|
tb_initial_acc_pl = self.env["account.move.line"].read_group(
|
|
356
479
|
domain=initial_domain_pl,
|
|
357
|
-
fields=["account_id", "balance", "amount_currency"],
|
|
358
|
-
groupby=
|
|
480
|
+
fields=["account_id", "balance", "amount_currency:sum"],
|
|
481
|
+
groupby=groupby_fields,
|
|
359
482
|
)
|
|
360
483
|
tb_initial_acc_rg = tb_initial_acc_bs + tb_initial_acc_pl
|
|
361
484
|
for account_rg in tb_initial_acc_rg:
|
|
@@ -369,6 +492,22 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
369
492
|
if element:
|
|
370
493
|
element[0]["balance"] += account_rg["balance"]
|
|
371
494
|
element[0]["amount_currency"] += account_rg["amount_currency"]
|
|
495
|
+
if "__context" in account_rg and "group_by" in account_rg["__context"]:
|
|
496
|
+
group_by = account_rg["__context"]["group_by"][0]
|
|
497
|
+
gb_data = {}
|
|
498
|
+
account_rg_grouped = self.env["account.move.line"].read_group(
|
|
499
|
+
domain=account_rg["__domain"],
|
|
500
|
+
fields=[group_by, "balance", "amount_currency:sum"],
|
|
501
|
+
groupby=[group_by],
|
|
502
|
+
)
|
|
503
|
+
for a_rg2 in account_rg_grouped:
|
|
504
|
+
gb_id = a_rg2[group_by][0] if a_rg2[group_by] else 0
|
|
505
|
+
gb_data[gb_id] = {
|
|
506
|
+
"balance": a_rg2["balance"],
|
|
507
|
+
"amount_currency": a_rg2["amount_currency"],
|
|
508
|
+
}
|
|
509
|
+
element[0]["group_by"] = group_by
|
|
510
|
+
element[0]["group_by_data"] = gb_data
|
|
372
511
|
if hide_account_at_0:
|
|
373
512
|
tb_initial_acc = [p for p in tb_initial_acc if p["balance"] != 0]
|
|
374
513
|
|
|
@@ -384,21 +523,21 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
384
523
|
)
|
|
385
524
|
tb_period_acc = self.env["account.move.line"].read_group(
|
|
386
525
|
domain=period_domain,
|
|
387
|
-
fields=["account_id", "debit", "credit", "balance", "amount_currency"],
|
|
388
|
-
groupby=
|
|
526
|
+
fields=["account_id", "debit", "credit", "balance", "amount_currency:sum"],
|
|
527
|
+
groupby=groupby_fields,
|
|
389
528
|
)
|
|
390
529
|
|
|
391
530
|
if show_partner_details:
|
|
392
531
|
tb_initial_prt_bs = self.env["account.move.line"].read_group(
|
|
393
532
|
domain=initial_domain_bs,
|
|
394
|
-
fields=["account_id", "partner_id", "balance", "amount_currency"],
|
|
395
|
-
groupby=["account_id", "partner_id"],
|
|
533
|
+
fields=["account_id", "partner_id", "balance", "amount_currency:sum"],
|
|
534
|
+
groupby=["account_id", "partner_id", "currency_id"],
|
|
396
535
|
lazy=False,
|
|
397
536
|
)
|
|
398
537
|
tb_initial_prt_pl = self.env["account.move.line"].read_group(
|
|
399
538
|
domain=initial_domain_pl,
|
|
400
|
-
fields=["account_id", "partner_id", "balance", "amount_currency"],
|
|
401
|
-
groupby=["account_id", "partner_id"],
|
|
539
|
+
fields=["account_id", "partner_id", "balance", "amount_currency:sum"],
|
|
540
|
+
groupby=["account_id", "partner_id", "currency_id"],
|
|
402
541
|
)
|
|
403
542
|
tb_initial_prt = tb_initial_prt_bs + tb_initial_prt_pl
|
|
404
543
|
if hide_account_at_0:
|
|
@@ -411,9 +550,9 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
411
550
|
"debit",
|
|
412
551
|
"credit",
|
|
413
552
|
"balance",
|
|
414
|
-
"amount_currency",
|
|
553
|
+
"amount_currency:sum",
|
|
415
554
|
],
|
|
416
|
-
groupby=["account_id", "partner_id"],
|
|
555
|
+
groupby=["account_id", "currency_id", "partner_id"],
|
|
417
556
|
lazy=False,
|
|
418
557
|
)
|
|
419
558
|
total_amount = {}
|
|
@@ -425,6 +564,11 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
425
564
|
total_amount, partners_data = self._compute_partner_amount(
|
|
426
565
|
total_amount, tb_initial_prt, tb_period_prt, foreign_currency
|
|
427
566
|
)
|
|
567
|
+
# Remove accounts a 0 from collections
|
|
568
|
+
if hide_account_at_0:
|
|
569
|
+
company = self.env["res.company"].browse(company_id)
|
|
570
|
+
self._remove_accounts_at_cero(total_amount, show_partner_details, company)
|
|
571
|
+
|
|
428
572
|
accounts_ids = list(total_amount.keys())
|
|
429
573
|
unaffected_id = unaffected_earnings_account
|
|
430
574
|
if unaffected_id:
|
|
@@ -437,8 +581,22 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
437
581
|
total_amount[unaffected_id]["debit"] = 0.0
|
|
438
582
|
total_amount[unaffected_id]["ending_balance"] = 0.0
|
|
439
583
|
if foreign_currency:
|
|
584
|
+
total_amount[unaffected_id]["amount_currency"] = 0
|
|
440
585
|
total_amount[unaffected_id]["initial_currency_balance"] = 0.0
|
|
441
586
|
total_amount[unaffected_id]["ending_currency_balance"] = 0.0
|
|
587
|
+
if grouped_by:
|
|
588
|
+
total_amount[unaffected_id]["group_by"] = grouped_by
|
|
589
|
+
total_amount[unaffected_id]["group_by_data"] = {}
|
|
590
|
+
# Fix to prevent side effects
|
|
591
|
+
if (
|
|
592
|
+
foreign_currency
|
|
593
|
+
and "amount_currency" not in total_amount[unaffected_id]
|
|
594
|
+
):
|
|
595
|
+
total_amount[unaffected_id]["amount_currency"] = 0
|
|
596
|
+
group_by_data_item = self._prepare_total_amount(
|
|
597
|
+
total_amount[unaffected_id], foreign_currency
|
|
598
|
+
)
|
|
599
|
+
total_amount[unaffected_id]["group_by_data"][0] = group_by_data_item
|
|
442
600
|
accounts_data = self._get_accounts_data(accounts_ids)
|
|
443
601
|
(
|
|
444
602
|
pl_initial_balance,
|
|
@@ -457,89 +615,164 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
457
615
|
total_amount[unaffected_id]["ending_balance"] += pl_initial_balance
|
|
458
616
|
total_amount[unaffected_id]["initial_balance"] += pl_initial_balance
|
|
459
617
|
if foreign_currency:
|
|
460
|
-
total_amount[unaffected_id][
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
total_amount[unaffected_id][
|
|
464
|
-
|
|
465
|
-
|
|
618
|
+
total_amount[unaffected_id]["ending_currency_balance"] += (
|
|
619
|
+
pl_initial_currency_balance
|
|
620
|
+
)
|
|
621
|
+
total_amount[unaffected_id]["initial_currency_balance"] += (
|
|
622
|
+
pl_initial_currency_balance
|
|
623
|
+
)
|
|
624
|
+
if grouped_by:
|
|
625
|
+
total_amount[unaffected_id]["group_by_data"][0]["ending_balance"] = (
|
|
626
|
+
total_amount[unaffected_id]["ending_balance"]
|
|
627
|
+
)
|
|
628
|
+
total_amount[unaffected_id]["group_by_data"][0]["initial_balance"] = (
|
|
629
|
+
total_amount[unaffected_id]["initial_balance"]
|
|
630
|
+
)
|
|
631
|
+
if foreign_currency:
|
|
632
|
+
total_amount[unaffected_id]["group_by_data"][0][
|
|
633
|
+
"ending_currency_balance"
|
|
634
|
+
] = total_amount[unaffected_id]["ending_currency_balance"]
|
|
635
|
+
total_amount[unaffected_id]["group_by_data"][0][
|
|
636
|
+
"initial_currency_balance"
|
|
637
|
+
] = total_amount[unaffected_id]["initial_currency_balance"]
|
|
466
638
|
return total_amount, accounts_data, partners_data
|
|
467
639
|
|
|
468
|
-
def
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
640
|
+
def _get_data_grouped(self, total_amount, accounts_data, foreign_currency):
|
|
641
|
+
"""Get the data grouped by analytical account instead of as used
|
|
642
|
+
"without grouping".
|
|
643
|
+
"""
|
|
644
|
+
trial_balance = {}
|
|
645
|
+
total_amount_grouped = {"type": "total", "name": _("TOTAL")}
|
|
646
|
+
f_names = [
|
|
647
|
+
"credit",
|
|
648
|
+
"debit",
|
|
649
|
+
"balance",
|
|
650
|
+
"initial_balance",
|
|
651
|
+
"ending_balance",
|
|
652
|
+
"initial_currency_balance",
|
|
653
|
+
"ending_currency_balance",
|
|
654
|
+
]
|
|
655
|
+
for f_name in f_names:
|
|
656
|
+
total_amount_grouped[f_name] = 0
|
|
657
|
+
for a_id in list(total_amount.keys()):
|
|
658
|
+
for key in list(total_amount[a_id]["group_by_data"].keys()):
|
|
659
|
+
total_amount_item2 = total_amount[a_id]["group_by_data"][key]
|
|
660
|
+
if key not in trial_balance:
|
|
661
|
+
trial_balance[key] = {}
|
|
662
|
+
for f_name in f_names:
|
|
663
|
+
if f_name in total_amount_item2:
|
|
664
|
+
trial_balance[key][f_name] = 0
|
|
665
|
+
trial_balance[key]["account_data"] = {}
|
|
666
|
+
for f_name in f_names:
|
|
667
|
+
if f_name in total_amount_item2:
|
|
668
|
+
trial_balance[key][f_name] += total_amount_item2[f_name]
|
|
669
|
+
# Prepare data_item
|
|
670
|
+
data_item = total_amount_item2
|
|
671
|
+
data_item["type"] = "account_type"
|
|
672
|
+
data_item["id"] = a_id
|
|
673
|
+
data_item["name"] = accounts_data[a_id]["name"]
|
|
674
|
+
data_item["code"] = accounts_data[a_id]["code"]
|
|
675
|
+
if foreign_currency:
|
|
676
|
+
data_item["currency_id"] = accounts_data[a_id]["currency_id"]
|
|
677
|
+
data_item["currency_name"] = accounts_data[a_id]["currency_name"]
|
|
678
|
+
trial_balance[key]["account_data"][a_id] = data_item
|
|
679
|
+
analytic_account_ids = list(trial_balance.keys())
|
|
680
|
+
aa_data = {}
|
|
681
|
+
aaa_model = self.env["account.analytic.account"].with_context(active_test=False)
|
|
682
|
+
analytic_accounts = aaa_model.search_read(
|
|
683
|
+
domain=[("id", "in", analytic_account_ids)],
|
|
684
|
+
fields=["display_name"],
|
|
685
|
+
)
|
|
686
|
+
for aa in analytic_accounts:
|
|
687
|
+
aa_data[aa["id"]] = aa
|
|
688
|
+
for aa_id in analytic_account_ids:
|
|
689
|
+
trial_balance[aa_id]["id"] = aa_id
|
|
690
|
+
trial_balance[aa_id]["type"] = "analytic_account_type"
|
|
691
|
+
trial_balance[aa_id]["name"] = (
|
|
692
|
+
aa_data[aa_id]["display_name"]
|
|
693
|
+
if aa_id in aa_data
|
|
694
|
+
else _("Without analytic account")
|
|
695
|
+
)
|
|
696
|
+
account_data_item = list(trial_balance[aa_id]["account_data"].values())
|
|
697
|
+
account_data_item = sorted(account_data_item, key=lambda k: k["code"])
|
|
698
|
+
trial_balance[aa_id]["account_data"] = account_data_item
|
|
699
|
+
for f_name in f_names:
|
|
700
|
+
if f_name in trial_balance[aa_id]:
|
|
701
|
+
total_amount_grouped[f_name] += trial_balance[aa_id][f_name]
|
|
702
|
+
trial_balance = list(trial_balance.values())
|
|
703
|
+
trial_balance = sorted(trial_balance, key=lambda k: k["name"])
|
|
704
|
+
return trial_balance, total_amount_grouped
|
|
705
|
+
|
|
706
|
+
def _get_hierarchy_groups(self, group_ids, groups_data, foreign_currency):
|
|
707
|
+
processed_groups = []
|
|
708
|
+
# Sort groups so that parent groups are processed before child groups
|
|
709
|
+
groups = (
|
|
710
|
+
self.env["account.group"]
|
|
711
|
+
.browse(group_ids)
|
|
712
|
+
.sorted(key=lambda x: x.complete_code)
|
|
713
|
+
)
|
|
714
|
+
for group in groups:
|
|
715
|
+
group_id = group.id
|
|
716
|
+
parent_id = groups_data[group_id]["parent_id"]
|
|
717
|
+
if group_id in processed_groups:
|
|
718
|
+
raise UserError(
|
|
719
|
+
_(
|
|
720
|
+
"There is a problem in the structure of the account groups. "
|
|
721
|
+
"You may need to create some child group of %s."
|
|
722
|
+
)
|
|
723
|
+
% groups_data[group_id]["name"]
|
|
724
|
+
)
|
|
725
|
+
else:
|
|
726
|
+
processed_groups.append(parent_id)
|
|
727
|
+
while parent_id:
|
|
728
|
+
if parent_id not in groups_data.keys():
|
|
729
|
+
group = self.env["account.group"].browse(parent_id)
|
|
730
|
+
groups_data[group.id] = {
|
|
521
731
|
"id": group.id,
|
|
522
732
|
"code": group.code_prefix_start,
|
|
523
733
|
"name": group.name,
|
|
524
734
|
"parent_id": group.parent_id.id,
|
|
525
|
-
"parent_path": group.parent_path,
|
|
526
735
|
"complete_code": group.complete_code,
|
|
527
736
|
"account_ids": group.compute_account_ids.ids,
|
|
528
737
|
"type": "group_type",
|
|
738
|
+
"initial_balance": 0,
|
|
739
|
+
"debit": 0,
|
|
740
|
+
"credit": 0,
|
|
741
|
+
"balance": 0,
|
|
742
|
+
"ending_balance": 0,
|
|
529
743
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
744
|
+
if foreign_currency:
|
|
745
|
+
groups_data[group.id].update(
|
|
746
|
+
initial_currency_balance=0,
|
|
747
|
+
ending_currency_balance=0,
|
|
748
|
+
)
|
|
749
|
+
acc_keys = ["debit", "credit", "balance"]
|
|
750
|
+
acc_keys += ["initial_balance", "ending_balance"]
|
|
751
|
+
for acc_key in acc_keys:
|
|
752
|
+
groups_data[parent_id][acc_key] += groups_data[group_id][acc_key]
|
|
753
|
+
if foreign_currency:
|
|
754
|
+
groups_data[group_id]["initial_currency_balance"] += groups_data[
|
|
755
|
+
group_id
|
|
756
|
+
]["initial_currency_balance"]
|
|
757
|
+
groups_data[group_id]["ending_currency_balance"] += groups_data[
|
|
758
|
+
group_id
|
|
759
|
+
]["ending_currency_balance"]
|
|
760
|
+
parent_id = groups_data[parent_id]["parent_id"]
|
|
534
761
|
return groups_data
|
|
535
762
|
|
|
536
763
|
def _get_groups_data(self, accounts_data, total_amount, foreign_currency):
|
|
537
764
|
accounts_ids = list(accounts_data.keys())
|
|
538
|
-
accounts =
|
|
765
|
+
accounts = (
|
|
766
|
+
self.env["account.account"]
|
|
767
|
+
.with_context(active_test=False)
|
|
768
|
+
.browse(accounts_ids)
|
|
769
|
+
)
|
|
539
770
|
account_group_relation = {}
|
|
540
771
|
for account in accounts:
|
|
541
772
|
accounts_data[account.id]["complete_code"] = (
|
|
542
|
-
account.group_id.complete_code
|
|
773
|
+
account.group_id.complete_code + " / " + account.code
|
|
774
|
+
if account.group_id.id
|
|
775
|
+
else ""
|
|
543
776
|
)
|
|
544
777
|
if account.group_id.id:
|
|
545
778
|
if account.group_id.id not in account_group_relation.keys():
|
|
@@ -556,7 +789,6 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
556
789
|
"code": group.code_prefix_start,
|
|
557
790
|
"name": group.name,
|
|
558
791
|
"parent_id": group.parent_id.id,
|
|
559
|
-
"parent_path": group.parent_path,
|
|
560
792
|
"type": "group_type",
|
|
561
793
|
"complete_code": group.complete_code,
|
|
562
794
|
"account_ids": group.compute_account_ids.ids,
|
|
@@ -590,9 +822,10 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
590
822
|
account_id
|
|
591
823
|
]["ending_currency_balance"]
|
|
592
824
|
group_ids = list(groups_data.keys())
|
|
593
|
-
old_group_ids = list(groups_data.keys())
|
|
594
825
|
groups_data = self._get_hierarchy_groups(
|
|
595
|
-
group_ids,
|
|
826
|
+
group_ids,
|
|
827
|
+
groups_data,
|
|
828
|
+
foreign_currency,
|
|
596
829
|
)
|
|
597
830
|
return groups_data
|
|
598
831
|
|
|
@@ -608,7 +841,6 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
608
841
|
"code": group.code_prefix_start,
|
|
609
842
|
"name": group.name,
|
|
610
843
|
"parent_id": group.parent_id.id,
|
|
611
|
-
"parent_path": group.parent_path,
|
|
612
844
|
"type": "group_type",
|
|
613
845
|
"complete_code": group.complete_code,
|
|
614
846
|
"account_ids": group.compute_account_ids.ids,
|
|
@@ -637,15 +869,16 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
637
869
|
"ending_balance"
|
|
638
870
|
]
|
|
639
871
|
if foreign_currency:
|
|
640
|
-
groups_data[group_id][
|
|
641
|
-
"initial_currency_balance"
|
|
642
|
-
|
|
643
|
-
groups_data[group_id][
|
|
644
|
-
"ending_currency_balance"
|
|
645
|
-
|
|
872
|
+
groups_data[group_id]["initial_currency_balance"] += (
|
|
873
|
+
total_amount[acc_id]["initial_currency_balance"]
|
|
874
|
+
)
|
|
875
|
+
groups_data[group_id]["ending_currency_balance"] += (
|
|
876
|
+
total_amount[acc_id]["ending_currency_balance"]
|
|
877
|
+
)
|
|
646
878
|
return groups_data
|
|
647
879
|
|
|
648
880
|
def _get_report_values(self, docids, data):
|
|
881
|
+
res = super()._get_report_values(docids, data)
|
|
649
882
|
show_partner_details = data["show_partner_details"]
|
|
650
883
|
wizard_id = data["wizard_id"]
|
|
651
884
|
company = self.env["res.company"].browse(data["company_id"])
|
|
@@ -656,12 +889,13 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
656
889
|
date_to = data["date_to"]
|
|
657
890
|
date_from = data["date_from"]
|
|
658
891
|
hide_account_at_0 = data["hide_account_at_0"]
|
|
659
|
-
|
|
892
|
+
show_hierarchy = data["show_hierarchy"]
|
|
660
893
|
show_hierarchy_level = data["show_hierarchy_level"]
|
|
661
894
|
foreign_currency = data["foreign_currency"]
|
|
662
895
|
only_posted_moves = data["only_posted_moves"]
|
|
663
896
|
unaffected_earnings_account = data["unaffected_earnings_account"]
|
|
664
897
|
fy_start_date = data["fy_start_date"]
|
|
898
|
+
grouped_by = data["grouped_by"]
|
|
665
899
|
total_amount, accounts_data, partners_data = self._get_data(
|
|
666
900
|
account_ids,
|
|
667
901
|
journal_ids,
|
|
@@ -675,7 +909,14 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
675
909
|
hide_account_at_0,
|
|
676
910
|
unaffected_earnings_account,
|
|
677
911
|
fy_start_date,
|
|
912
|
+
grouped_by,
|
|
678
913
|
)
|
|
914
|
+
trial_balance_grouped = False
|
|
915
|
+
total_amount_grouped = False
|
|
916
|
+
if grouped_by:
|
|
917
|
+
trial_balance_grouped, total_amount_grouped = self._get_data_grouped(
|
|
918
|
+
total_amount, accounts_data, foreign_currency
|
|
919
|
+
)
|
|
679
920
|
trial_balance = []
|
|
680
921
|
if not show_partner_details:
|
|
681
922
|
for account_id in accounts_data.keys():
|
|
@@ -686,6 +927,16 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
686
927
|
"debit": total_amount[account_id]["debit"],
|
|
687
928
|
"balance": total_amount[account_id]["balance"],
|
|
688
929
|
"ending_balance": total_amount[account_id]["ending_balance"],
|
|
930
|
+
"group_by": (
|
|
931
|
+
total_amount[account_id]["group_by"]
|
|
932
|
+
if "group_by" in total_amount[account_id]
|
|
933
|
+
else False
|
|
934
|
+
),
|
|
935
|
+
"group_by_data": (
|
|
936
|
+
total_amount[account_id]["group_by_data"]
|
|
937
|
+
if "group_by_data" in total_amount[account_id]
|
|
938
|
+
else False
|
|
939
|
+
),
|
|
689
940
|
"type": "account_type",
|
|
690
941
|
}
|
|
691
942
|
)
|
|
@@ -700,7 +951,7 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
700
951
|
],
|
|
701
952
|
}
|
|
702
953
|
)
|
|
703
|
-
if
|
|
954
|
+
if show_hierarchy:
|
|
704
955
|
groups_data = self._get_groups_data(
|
|
705
956
|
accounts_data, total_amount, foreign_currency
|
|
706
957
|
)
|
|
@@ -710,14 +961,7 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
710
961
|
for trial in trial_balance:
|
|
711
962
|
counter = trial["complete_code"].count("/")
|
|
712
963
|
trial["level"] = counter
|
|
713
|
-
|
|
714
|
-
groups_data = self._get_computed_groups_data(
|
|
715
|
-
accounts_data, total_amount, foreign_currency
|
|
716
|
-
)
|
|
717
|
-
trial_balance = list(groups_data.values())
|
|
718
|
-
trial_balance += list(accounts_data.values())
|
|
719
|
-
trial_balance = sorted(trial_balance, key=lambda k: k["code"])
|
|
720
|
-
if hierarchy_on == "none":
|
|
964
|
+
else:
|
|
721
965
|
trial_balance = list(accounts_data.values())
|
|
722
966
|
trial_balance = sorted(trial_balance, key=lambda k: k["code"])
|
|
723
967
|
else:
|
|
@@ -729,24 +973,32 @@ class TrialBalanceReport(models.AbstractModel):
|
|
|
729
973
|
total_amount[account_id]["currency_name"] = accounts_data[
|
|
730
974
|
account_id
|
|
731
975
|
]["currency_name"]
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
976
|
+
res.update(
|
|
977
|
+
{
|
|
978
|
+
"doc_ids": [wizard_id],
|
|
979
|
+
"doc_model": "trial.balance.report.wizard",
|
|
980
|
+
"docs": self.env["trial.balance.report.wizard"].browse(wizard_id),
|
|
981
|
+
"foreign_currency": data["foreign_currency"],
|
|
982
|
+
"company_name": company.display_name,
|
|
983
|
+
"company_currency": company.currency_id,
|
|
984
|
+
"currency_name": company.currency_id.name,
|
|
985
|
+
"date_from": data["date_from"],
|
|
986
|
+
"date_to": data["date_to"],
|
|
987
|
+
"only_posted_moves": data["only_posted_moves"],
|
|
988
|
+
"hide_account_at_0": data["hide_account_at_0"],
|
|
989
|
+
"show_partner_details": data["show_partner_details"],
|
|
990
|
+
"limit_hierarchy_level": data["limit_hierarchy_level"],
|
|
991
|
+
"show_hierarchy": show_hierarchy,
|
|
992
|
+
"hide_parent_hierarchy_level": data["hide_parent_hierarchy_level"],
|
|
993
|
+
"trial_balance": trial_balance,
|
|
994
|
+
"trial_balance_grouped": trial_balance_grouped,
|
|
995
|
+
"total_amount": total_amount,
|
|
996
|
+
"total_amount_grouped": total_amount_grouped,
|
|
997
|
+
"accounts_data": accounts_data,
|
|
998
|
+
"partners_data": partners_data,
|
|
999
|
+
"show_hierarchy_level": show_hierarchy_level,
|
|
1000
|
+
"currency_model": self.env["res.currency"],
|
|
1001
|
+
"grouped_by": grouped_by,
|
|
1002
|
+
}
|
|
1003
|
+
)
|
|
1004
|
+
return res
|