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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Author: Julien Coux
|
|
3
3
|
# Copyright 2016 Camptocamp SA
|
|
4
4
|
# Copyright 2021 Tecnativa - João Marques
|
|
5
|
+
# Copyright 2022 Tecnativa - V??ctor Mart??nez
|
|
5
6
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
6
7
|
|
|
7
8
|
from odoo import _, models
|
|
@@ -17,7 +18,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
17
18
|
report_name = _("General Ledger")
|
|
18
19
|
if company_id:
|
|
19
20
|
company = self.env["res.company"].browse(company_id)
|
|
20
|
-
suffix = " - {} - {
|
|
21
|
+
suffix = f" - {company.name} - {company.currency_id.name}"
|
|
21
22
|
report_name = report_name + suffix
|
|
22
23
|
return report_name
|
|
23
24
|
|
|
@@ -34,15 +35,11 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
34
35
|
if report.show_cost_center:
|
|
35
36
|
res += [
|
|
36
37
|
{
|
|
37
|
-
"header": _("Analytic
|
|
38
|
-
"field": "
|
|
38
|
+
"header": _("Analytic Distribution"),
|
|
39
|
+
"field": "analytic_distribution",
|
|
39
40
|
"width": 20,
|
|
40
41
|
},
|
|
41
42
|
]
|
|
42
|
-
if report.show_analytic_tags:
|
|
43
|
-
res += [
|
|
44
|
-
{"header": _("Tags"), "field": "tags", "width": 10},
|
|
45
|
-
]
|
|
46
43
|
res += [
|
|
47
44
|
{"header": _("Rec."), "field": "rec_name", "width": 15},
|
|
48
45
|
{
|
|
@@ -72,20 +69,21 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
72
69
|
]
|
|
73
70
|
if report.foreign_currency:
|
|
74
71
|
res += [
|
|
75
|
-
{
|
|
76
|
-
"header": _("Cur."),
|
|
77
|
-
"field": "currency_name",
|
|
78
|
-
"field_currency_balance": "currency_name",
|
|
79
|
-
"type": "currency_name",
|
|
80
|
-
"width": 7,
|
|
81
|
-
},
|
|
82
72
|
{
|
|
83
73
|
"header": _("Amount cur."),
|
|
84
74
|
"field": "bal_curr",
|
|
85
75
|
"field_initial_balance": "initial_bal_curr",
|
|
86
76
|
"field_final_balance": "final_bal_curr",
|
|
87
77
|
"type": "amount_currency",
|
|
88
|
-
"width":
|
|
78
|
+
"width": 10,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"header": _("Cumul cur."),
|
|
82
|
+
"field": "total_bal_curr",
|
|
83
|
+
"field_initial_balance": "initial_bal_curr",
|
|
84
|
+
"field_final_balance": "final_bal_curr",
|
|
85
|
+
"type": "amount_currency",
|
|
86
|
+
"width": 10,
|
|
89
87
|
},
|
|
90
88
|
]
|
|
91
89
|
res_as_dict = {}
|
|
@@ -111,10 +109,6 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
111
109
|
_("Hide") if report.hide_account_at_0 else _("Show"),
|
|
112
110
|
],
|
|
113
111
|
[_("Centralize filter"), _("Yes") if report.centralize else _("No")],
|
|
114
|
-
[
|
|
115
|
-
_("Show analytic tags"),
|
|
116
|
-
_("Yes") if report.show_analytic_tags else _("No"),
|
|
117
|
-
],
|
|
118
112
|
[
|
|
119
113
|
_("Show foreign currency"),
|
|
120
114
|
_("Yes") if report.foreign_currency else _("No"),
|
|
@@ -143,21 +137,22 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
143
137
|
]._get_report_values(report, data)
|
|
144
138
|
general_ledger = res_data["general_ledger"]
|
|
145
139
|
accounts_data = res_data["accounts_data"]
|
|
146
|
-
partners_data = res_data["partners_data"]
|
|
147
140
|
journals_data = res_data["journals_data"]
|
|
148
141
|
taxes_data = res_data["taxes_data"]
|
|
149
|
-
|
|
142
|
+
analytic_data = res_data["analytic_data"]
|
|
150
143
|
filter_partner_ids = res_data["filter_partner_ids"]
|
|
151
144
|
foreign_currency = res_data["foreign_currency"]
|
|
145
|
+
company_currency = res_data["company_currency"]
|
|
152
146
|
# For each account
|
|
153
147
|
for account in general_ledger:
|
|
154
148
|
# Write account title
|
|
149
|
+
total_bal_curr = 0
|
|
155
150
|
self.write_array_title(
|
|
156
151
|
account["code"] + " - " + accounts_data[account["id"]]["name"],
|
|
157
152
|
report_data,
|
|
158
153
|
)
|
|
159
154
|
|
|
160
|
-
if not account
|
|
155
|
+
if "list_grouped" not in account:
|
|
161
156
|
# Display array header for move lines
|
|
162
157
|
self.write_array_header(report_data)
|
|
163
158
|
|
|
@@ -169,7 +164,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
169
164
|
"initial_balance": account["init_bal"]["balance"],
|
|
170
165
|
}
|
|
171
166
|
)
|
|
172
|
-
if foreign_currency:
|
|
167
|
+
if foreign_currency and account["currency_id"]:
|
|
173
168
|
account.update(
|
|
174
169
|
{"initial_bal_curr": account["init_bal"]["bal_curr"]}
|
|
175
170
|
)
|
|
@@ -183,7 +178,10 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
183
178
|
"journal": journals_data[line["journal_id"]]["code"],
|
|
184
179
|
}
|
|
185
180
|
)
|
|
186
|
-
|
|
181
|
+
line_currency_id = (
|
|
182
|
+
line["currency_id"][0] if line["currency_id"] else False
|
|
183
|
+
)
|
|
184
|
+
if line_currency_id and line_currency_id != company_currency.id:
|
|
187
185
|
line.update(
|
|
188
186
|
{
|
|
189
187
|
"currency_name": line["currency_id"][1],
|
|
@@ -192,17 +190,35 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
192
190
|
)
|
|
193
191
|
if line["ref_label"] != "Centralized entries":
|
|
194
192
|
taxes_description = ""
|
|
195
|
-
|
|
193
|
+
analytic_distribution = ""
|
|
196
194
|
for tax_id in line["tax_ids"]:
|
|
197
195
|
taxes_description += taxes_data[tax_id]["tax_name"] + " "
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
if line["tax_line_id"]:
|
|
197
|
+
taxes_description += line["tax_line_id"][1]
|
|
198
|
+
for account_ids, value in line["analytic_distribution"].items():
|
|
199
|
+
for account_id in account_ids.split(","):
|
|
200
|
+
if value < 100:
|
|
201
|
+
analytic_distribution += "%s %d%% " % (
|
|
202
|
+
analytic_data[int(account_id)]["name"],
|
|
203
|
+
value,
|
|
204
|
+
)
|
|
205
|
+
else:
|
|
206
|
+
analytic_distribution += (
|
|
207
|
+
f"{analytic_data[int(account_id)]['name']} "
|
|
208
|
+
)
|
|
200
209
|
line.update(
|
|
201
210
|
{
|
|
202
211
|
"taxes_description": taxes_description,
|
|
203
|
-
"
|
|
212
|
+
"analytic_distribution": analytic_distribution,
|
|
204
213
|
}
|
|
205
214
|
)
|
|
215
|
+
if (
|
|
216
|
+
foreign_currency
|
|
217
|
+
and line_currency_id
|
|
218
|
+
and line_currency_id != company_currency.id
|
|
219
|
+
):
|
|
220
|
+
total_bal_curr += line["bal_curr"]
|
|
221
|
+
line.update({"total_bal_curr": total_bal_curr})
|
|
206
222
|
self.write_line_from_dict(line, report_data)
|
|
207
223
|
# Display ending balance line for account
|
|
208
224
|
account.update(
|
|
@@ -212,7 +228,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
212
228
|
"final_balance": account["fin_bal"]["balance"],
|
|
213
229
|
}
|
|
214
230
|
)
|
|
215
|
-
if foreign_currency:
|
|
231
|
+
if foreign_currency and account["currency_id"]:
|
|
216
232
|
account.update(
|
|
217
233
|
{
|
|
218
234
|
"final_bal_curr": account["fin_bal"]["bal_curr"],
|
|
@@ -222,43 +238,59 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
222
238
|
|
|
223
239
|
else:
|
|
224
240
|
# For each partner
|
|
225
|
-
|
|
241
|
+
total_bal_curr = 0
|
|
242
|
+
for group_item in account["list_grouped"]:
|
|
226
243
|
# Write partner title
|
|
227
|
-
self.write_array_title(
|
|
228
|
-
partners_data[partner["id"]]["name"], report_data
|
|
229
|
-
)
|
|
244
|
+
self.write_array_title(group_item["name"], report_data)
|
|
230
245
|
|
|
231
246
|
# Display array header for move lines
|
|
232
247
|
self.write_array_header(report_data)
|
|
233
248
|
|
|
249
|
+
account.update(
|
|
250
|
+
{
|
|
251
|
+
"currency_id": accounts_data[account["id"]]["currency_id"],
|
|
252
|
+
"currency_name": accounts_data[account["id"]][
|
|
253
|
+
"currency_name"
|
|
254
|
+
],
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
|
|
234
258
|
# Display initial balance line for partner
|
|
235
|
-
|
|
259
|
+
group_item.update(
|
|
236
260
|
{
|
|
237
|
-
"initial_debit":
|
|
238
|
-
"initial_credit":
|
|
239
|
-
"initial_balance":
|
|
240
|
-
"name": partners_data[partner["id"]]["name"],
|
|
261
|
+
"initial_debit": group_item["init_bal"]["debit"],
|
|
262
|
+
"initial_credit": group_item["init_bal"]["credit"],
|
|
263
|
+
"initial_balance": group_item["init_bal"]["balance"],
|
|
241
264
|
"type": "partner",
|
|
265
|
+
"grouped_by": account["grouped_by"]
|
|
266
|
+
if "grouped_by" in account
|
|
267
|
+
else "",
|
|
242
268
|
"currency_id": accounts_data[account["id"]]["currency_id"],
|
|
269
|
+
"currency_name": accounts_data[account["id"]][
|
|
270
|
+
"currency_name"
|
|
271
|
+
],
|
|
243
272
|
}
|
|
244
273
|
)
|
|
245
|
-
if foreign_currency:
|
|
246
|
-
|
|
274
|
+
if foreign_currency and account["currency_id"]:
|
|
275
|
+
group_item.update(
|
|
247
276
|
{
|
|
248
|
-
"initial_bal_curr":
|
|
277
|
+
"initial_bal_curr": group_item["init_bal"]["bal_curr"],
|
|
249
278
|
}
|
|
250
279
|
)
|
|
251
|
-
self.write_initial_balance_from_dict(
|
|
280
|
+
self.write_initial_balance_from_dict(group_item, report_data)
|
|
252
281
|
|
|
253
282
|
# Display account move lines
|
|
254
|
-
for line in
|
|
283
|
+
for line in group_item["move_lines"]:
|
|
255
284
|
line.update(
|
|
256
285
|
{
|
|
257
286
|
"account": account["code"],
|
|
258
287
|
"journal": journals_data[line["journal_id"]]["code"],
|
|
259
288
|
}
|
|
260
289
|
)
|
|
261
|
-
|
|
290
|
+
line_currency_id = (
|
|
291
|
+
line["currency_id"][0] if line["currency_id"] else False
|
|
292
|
+
)
|
|
293
|
+
if line_currency_id and line_currency_id != company_currency.id:
|
|
262
294
|
line.update(
|
|
263
295
|
{
|
|
264
296
|
"currency_name": line["currency_id"][1],
|
|
@@ -267,38 +299,54 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
267
299
|
)
|
|
268
300
|
if line["ref_label"] != "Centralized entries":
|
|
269
301
|
taxes_description = ""
|
|
270
|
-
|
|
302
|
+
analytic_distribution = ""
|
|
271
303
|
for tax_id in line["tax_ids"]:
|
|
272
304
|
taxes_description += (
|
|
273
305
|
taxes_data[tax_id]["tax_name"] + " "
|
|
274
306
|
)
|
|
275
|
-
for
|
|
276
|
-
|
|
307
|
+
for account_ids, value in line[
|
|
308
|
+
"analytic_distribution"
|
|
309
|
+
].items():
|
|
310
|
+
for account_id in account_ids.split(","):
|
|
311
|
+
if value < 100:
|
|
312
|
+
analytic_distribution += "%s %d%% " % (
|
|
313
|
+
analytic_data[int(account_id)]["name"],
|
|
314
|
+
value,
|
|
315
|
+
)
|
|
316
|
+
else:
|
|
317
|
+
analytic_distribution += (
|
|
318
|
+
f"{analytic_data[int(account_id)]['name']} "
|
|
319
|
+
)
|
|
277
320
|
line.update(
|
|
278
321
|
{
|
|
279
322
|
"taxes_description": taxes_description,
|
|
280
|
-
"
|
|
323
|
+
"analytic_distribution": analytic_distribution,
|
|
281
324
|
}
|
|
282
325
|
)
|
|
326
|
+
if (
|
|
327
|
+
foreign_currency
|
|
328
|
+
and line_currency_id
|
|
329
|
+
and line_currency_id != company_currency.id
|
|
330
|
+
):
|
|
331
|
+
total_bal_curr += line["bal_curr"]
|
|
332
|
+
line.update({"total_bal_curr": total_bal_curr})
|
|
283
333
|
self.write_line_from_dict(line, report_data)
|
|
284
334
|
|
|
285
335
|
# Display ending balance line for partner
|
|
286
|
-
|
|
336
|
+
group_item.update(
|
|
287
337
|
{
|
|
288
|
-
"final_debit":
|
|
289
|
-
"final_credit":
|
|
290
|
-
"final_balance":
|
|
338
|
+
"final_debit": group_item["fin_bal"]["debit"],
|
|
339
|
+
"final_credit": group_item["fin_bal"]["credit"],
|
|
340
|
+
"final_balance": group_item["fin_bal"]["balance"],
|
|
291
341
|
}
|
|
292
342
|
)
|
|
293
|
-
if foreign_currency and
|
|
294
|
-
|
|
343
|
+
if foreign_currency and group_item["currency_id"]:
|
|
344
|
+
group_item.update(
|
|
295
345
|
{
|
|
296
|
-
"final_bal_curr":
|
|
297
|
-
"currency_name": partner["currency_id"].name,
|
|
298
|
-
"currency_id": partner["currency_id"].id,
|
|
346
|
+
"final_bal_curr": group_item["fin_bal"]["bal_curr"],
|
|
299
347
|
}
|
|
300
348
|
)
|
|
301
|
-
self.write_ending_balance_from_dict(
|
|
349
|
+
self.write_ending_balance_from_dict(group_item, report_data)
|
|
302
350
|
|
|
303
351
|
# Line break
|
|
304
352
|
report_data["row_pos"] += 1
|
|
@@ -311,12 +359,11 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
311
359
|
"final_balance": account["fin_bal"]["balance"],
|
|
312
360
|
}
|
|
313
361
|
)
|
|
314
|
-
if foreign_currency and account["
|
|
362
|
+
if foreign_currency and account["fin_bal_currency_id"]:
|
|
315
363
|
account.update(
|
|
316
364
|
{
|
|
317
|
-
"final_bal_curr":
|
|
318
|
-
"
|
|
319
|
-
"currency_id": account["currency_id"].id,
|
|
365
|
+
"final_bal_curr": total_bal_curr,
|
|
366
|
+
"currency_id": account["fin_bal_currency_id"],
|
|
320
367
|
}
|
|
321
368
|
)
|
|
322
369
|
self.write_ending_balance_from_dict(account, report_data)
|
|
@@ -326,22 +373,27 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|
|
326
373
|
|
|
327
374
|
def write_initial_balance_from_dict(self, my_object, report_data):
|
|
328
375
|
"""Specific function to write initial balance for General Ledger"""
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
)
|
|
376
|
+
label = False
|
|
377
|
+
if "account" not in my_object["type"] and "grouped_by" in my_object:
|
|
378
|
+
if my_object["grouped_by"] == "partners":
|
|
379
|
+
label = _("Partner Initial balance")
|
|
380
|
+
elif my_object["grouped_by"] == "taxes":
|
|
381
|
+
label = _("Tax Initial balance")
|
|
382
|
+
label = label if label else _("Initial balance")
|
|
383
|
+
return super().write_initial_balance_from_dict(my_object, label, report_data)
|
|
336
384
|
|
|
337
385
|
def write_ending_balance_from_dict(self, my_object, report_data):
|
|
338
386
|
"""Specific function to write ending balance for General Ledger"""
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
label = _("Partner ending balance")
|
|
342
|
-
elif "account" in my_object["type"]:
|
|
387
|
+
label = name = False
|
|
388
|
+
if "account" in my_object["type"]:
|
|
343
389
|
name = my_object["code"] + " - " + my_object["name"]
|
|
344
|
-
|
|
345
|
-
|
|
390
|
+
elif "grouped_by" in my_object:
|
|
391
|
+
name = my_object["name"]
|
|
392
|
+
if my_object["grouped_by"] == "partners":
|
|
393
|
+
label = _("Partner ending balance")
|
|
394
|
+
elif my_object["grouped_by"] == "taxes":
|
|
395
|
+
label = _("Tax ending balance")
|
|
396
|
+
label = label if label else _("Ending balance")
|
|
397
|
+
return super().write_ending_balance_from_dict(
|
|
346
398
|
my_object, name, label, report_data
|
|
347
399
|
)
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import itertools
|
|
5
5
|
import operator
|
|
6
|
+
from collections import defaultdict
|
|
6
7
|
|
|
7
8
|
from odoo import models
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class JournalLedgerReport(models.AbstractModel):
|
|
12
|
+
_inherit = "report.account_financial_report.abstract_report"
|
|
11
13
|
_name = "report.account_financial_report.journal_ledger"
|
|
12
14
|
_description = "Journal Ledger Report"
|
|
13
15
|
|
|
@@ -32,9 +34,13 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
32
34
|
return domain
|
|
33
35
|
|
|
34
36
|
def _get_journal_ledgers(self, wizard, journal_ids, company):
|
|
35
|
-
journals =
|
|
36
|
-
self.
|
|
37
|
-
|
|
37
|
+
journals = (
|
|
38
|
+
self.env["account.journal"]
|
|
39
|
+
.with_context(active_test=False)
|
|
40
|
+
.search(
|
|
41
|
+
self._get_journal_ledgers_domain(wizard, journal_ids, company),
|
|
42
|
+
order="name asc",
|
|
43
|
+
)
|
|
38
44
|
)
|
|
39
45
|
journal_ledgers_data = []
|
|
40
46
|
for journal in journals:
|
|
@@ -81,15 +87,21 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
81
87
|
return moves.ids, Moves, move_data
|
|
82
88
|
|
|
83
89
|
def _get_move_lines_domain(self, move_ids, wizard, journal_ids):
|
|
84
|
-
return [
|
|
90
|
+
return [
|
|
91
|
+
("display_type", "not in", ["line_note", "line_section"]),
|
|
92
|
+
("move_id", "in", move_ids),
|
|
93
|
+
]
|
|
85
94
|
|
|
86
95
|
def _get_move_lines_order(self, move_ids, wizard, journal_ids):
|
|
87
|
-
|
|
96
|
+
"""Add `move_id` to make sure the order of the records is correct
|
|
97
|
+
(especially if we use auto-sequence).
|
|
98
|
+
"""
|
|
99
|
+
return "move_id"
|
|
88
100
|
|
|
89
101
|
def _get_move_lines_data(self, ml, wizard, ml_taxes, auto_sequence, exigible):
|
|
90
|
-
base_debit = (
|
|
91
|
-
|
|
92
|
-
) =
|
|
102
|
+
base_debit = base_credit = tax_debit = tax_credit = base_balance = (
|
|
103
|
+
tax_balance
|
|
104
|
+
) = 0.0
|
|
93
105
|
if exigible:
|
|
94
106
|
base_debit = ml_taxes and ml.debit or 0.0
|
|
95
107
|
base_credit = ml_taxes and ml.credit or 0.0
|
|
@@ -131,7 +143,7 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
131
143
|
return {
|
|
132
144
|
"name": account.name,
|
|
133
145
|
"code": account.code,
|
|
134
|
-
"
|
|
146
|
+
"account_type": account.account_type,
|
|
135
147
|
}
|
|
136
148
|
|
|
137
149
|
def _get_partner_data(self, partners):
|
|
@@ -175,13 +187,23 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
175
187
|
return {"move_line_ids": tuple(move_lines.ids)}
|
|
176
188
|
|
|
177
189
|
def _get_move_lines(self, move_ids, wizard, journal_ids):
|
|
178
|
-
move_lines =
|
|
179
|
-
self.
|
|
180
|
-
|
|
190
|
+
move_lines = (
|
|
191
|
+
self.env["account.move.line"]
|
|
192
|
+
.with_context(prefetch_fields=False)
|
|
193
|
+
.search(
|
|
194
|
+
self._get_move_lines_domain(move_ids, wizard, journal_ids),
|
|
195
|
+
order=self._get_move_lines_order(move_ids, wizard, journal_ids),
|
|
196
|
+
)
|
|
181
197
|
)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
# Get the exigible move lines ids instead of the recordset to increase
|
|
199
|
+
# performance with a large number of journal items
|
|
200
|
+
move_lines_exigible_ids = set(
|
|
201
|
+
self.env["account.move.line"]
|
|
202
|
+
.search(
|
|
203
|
+
self._get_move_lines_domain(move_ids, wizard, journal_ids)
|
|
204
|
+
+ self.env["account.move.line"]._get_tax_exigible_domain(),
|
|
205
|
+
)
|
|
206
|
+
.ids
|
|
185
207
|
)
|
|
186
208
|
move_line_ids_taxes_data = {}
|
|
187
209
|
if move_lines:
|
|
@@ -203,36 +225,24 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
203
225
|
"description": tax_description,
|
|
204
226
|
}
|
|
205
227
|
Move_Lines = {}
|
|
206
|
-
accounts = self.env["account.account"]
|
|
207
|
-
partners = self.env["res.partner"]
|
|
208
|
-
currencies = self.env["res.currency"]
|
|
209
|
-
tax_lines = self.env["account.tax"]
|
|
210
228
|
auto_sequence = len(move_ids)
|
|
229
|
+
Move_Lines = defaultdict(list)
|
|
211
230
|
for ml in move_lines:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if ml.partner_id not in partners:
|
|
215
|
-
partners |= ml.partner_id
|
|
216
|
-
if ml.currency_id not in currencies:
|
|
217
|
-
currencies |= ml.currency_id
|
|
218
|
-
if ml.tax_line_id not in tax_lines:
|
|
219
|
-
tax_lines |= ml.tax_line_id
|
|
220
|
-
if ml.move_id.id not in Move_Lines.keys():
|
|
221
|
-
Move_Lines[ml.move_id.id] = []
|
|
231
|
+
move_id = ml.move_id.id
|
|
232
|
+
if move_id not in Move_Lines:
|
|
222
233
|
auto_sequence -= 1
|
|
223
|
-
taxes = (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
Move_Lines[ml.move_id.id].append(
|
|
234
|
+
taxes = move_line_ids_taxes_data.get(ml.id, {})
|
|
235
|
+
# Check the exigibility of the move line by id
|
|
236
|
+
# this way we avoid the recreation of the recordset which affects to the
|
|
237
|
+
# performance in the case of a large number of journal items
|
|
238
|
+
exigible = ml.id in move_lines_exigible_ids
|
|
239
|
+
Move_Lines[move_id].append(
|
|
230
240
|
self._get_move_lines_data(ml, wizard, taxes, auto_sequence, exigible)
|
|
231
241
|
)
|
|
232
|
-
account_ids_data = self._get_account_data(
|
|
233
|
-
partner_ids_data = self._get_partner_data(
|
|
234
|
-
currency_ids_data = self._get_currency_data(
|
|
235
|
-
tax_line_ids_data = self._get_tax_line_data(
|
|
242
|
+
account_ids_data = self._get_account_data(move_lines.account_id)
|
|
243
|
+
partner_ids_data = self._get_partner_data(move_lines.partner_id)
|
|
244
|
+
currency_ids_data = self._get_currency_data(move_lines.currency_id)
|
|
245
|
+
tax_line_ids_data = self._get_tax_line_data(move_lines.tax_line_id)
|
|
236
246
|
return (
|
|
237
247
|
move_lines.ids,
|
|
238
248
|
Move_Lines,
|
|
@@ -258,7 +268,11 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
258
268
|
journal_id = ml_data["journal_id"]
|
|
259
269
|
if journal_id not in journals_taxes_data.keys():
|
|
260
270
|
journals_taxes_data[journal_id] = {}
|
|
261
|
-
taxes =
|
|
271
|
+
taxes = (
|
|
272
|
+
self.env["account.tax"]
|
|
273
|
+
.with_context(active_test=False)
|
|
274
|
+
.search_fetch([("id", "in", tax_ids)], ["name", "description"])
|
|
275
|
+
)
|
|
262
276
|
for tax in taxes:
|
|
263
277
|
if tax.id not in journals_taxes_data[journal_id]:
|
|
264
278
|
journals_taxes_data[journal_id][tax.id] = {
|
|
@@ -293,6 +307,7 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
293
307
|
return journals_taxes_data_2
|
|
294
308
|
|
|
295
309
|
def _get_report_values(self, docids, data):
|
|
310
|
+
res = super()._get_report_values(docids, data)
|
|
296
311
|
wizard_id = data["wizard_id"]
|
|
297
312
|
wizard = self.env["journal.ledger.report.wizard"].browse(wizard_id)
|
|
298
313
|
company = self.env["res.company"].browse(data["company_id"])
|
|
@@ -306,11 +321,9 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
306
321
|
if key not in journal_moves_data.keys():
|
|
307
322
|
journal_moves_data[key] = []
|
|
308
323
|
journal_moves_data[key] += list(items)
|
|
309
|
-
move_lines_data = (
|
|
310
|
-
|
|
311
|
-
) =
|
|
312
|
-
partner_ids_data
|
|
313
|
-
) = currency_ids_data = tax_line_ids_data = move_line_ids_taxes_data = {}
|
|
324
|
+
move_lines_data = account_ids_data = partner_ids_data = currency_ids_data = (
|
|
325
|
+
tax_line_ids_data
|
|
326
|
+
) = move_line_ids_taxes_data = {}
|
|
314
327
|
if move_ids:
|
|
315
328
|
move_lines = self._get_move_lines(move_ids, wizard, journal_ids)
|
|
316
329
|
move_lines_data = move_lines[1]
|
|
@@ -346,25 +359,28 @@ class JournalLedgerReport(models.AbstractModel):
|
|
|
346
359
|
if journal_id in journal_totals.keys():
|
|
347
360
|
for item in ["debit", "credit"]:
|
|
348
361
|
journal_ledger_data[item] += journal_totals[journal_id][item]
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
362
|
+
res.update(
|
|
363
|
+
{
|
|
364
|
+
"doc_ids": [wizard_id],
|
|
365
|
+
"doc_model": "journal.ledger.report.wizard",
|
|
366
|
+
"docs": self.env["journal.ledger.report.wizard"].browse(wizard_id),
|
|
367
|
+
"group_option": data["group_option"],
|
|
368
|
+
"foreign_currency": data["foreign_currency"],
|
|
369
|
+
"with_account_name": data["with_account_name"],
|
|
370
|
+
"company_name": company.display_name,
|
|
371
|
+
"currency_name": company.currency_id.name,
|
|
372
|
+
"date_from": data["date_from"],
|
|
373
|
+
"date_to": data["date_to"],
|
|
374
|
+
"move_target": data["move_target"],
|
|
375
|
+
"with_auto_sequence": data["with_auto_sequence"],
|
|
376
|
+
"account_ids_data": account_ids_data,
|
|
377
|
+
"partner_ids_data": partner_ids_data,
|
|
378
|
+
"currency_ids_data": currency_ids_data,
|
|
379
|
+
"move_ids_data": move_ids_data,
|
|
380
|
+
"tax_line_data": tax_line_ids_data,
|
|
381
|
+
"move_line_ids_taxes_data": move_line_ids_taxes_data,
|
|
382
|
+
"Journal_Ledgers": journal_ledgers_data,
|
|
383
|
+
"Moves": moves_data,
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
return res
|