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
|
@@ -75,9 +75,7 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
75
75
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
|
76
76
|
),
|
|
77
77
|
"format_amount": workbook.add_format(),
|
|
78
|
-
"format_amount_bold": workbook.add_format({"bold": True})
|
|
79
|
-
"#,##0." + "0" * currency_id.decimal_places
|
|
80
|
-
),
|
|
78
|
+
"format_amount_bold": workbook.add_format({"bold": True}),
|
|
81
79
|
"format_percent_bold_italic": workbook.add_format(
|
|
82
80
|
{"bold": True, "italic": True}
|
|
83
81
|
),
|
|
@@ -89,6 +87,9 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
89
87
|
"#,##0." + "0" * currency_id.decimal_places
|
|
90
88
|
)
|
|
91
89
|
report_data["formats"]["format_percent_bold_italic"].set_num_format("#,##0.00%")
|
|
90
|
+
report_data["formats"]["format_amount_bold"].set_num_format(
|
|
91
|
+
"#,##0." + "0" * currency_id.decimal_places
|
|
92
|
+
)
|
|
92
93
|
|
|
93
94
|
def _set_column_width(self, report_data):
|
|
94
95
|
"""Set width for all defined columns.
|
|
@@ -238,10 +239,7 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
238
239
|
value = line_dict.get(column["field"], False)
|
|
239
240
|
cell_type = column.get("type", "string")
|
|
240
241
|
if cell_type == "string":
|
|
241
|
-
if (
|
|
242
|
-
line_dict.get("account_group_id", False)
|
|
243
|
-
and line_dict["account_group_id"]
|
|
244
|
-
):
|
|
242
|
+
if line_dict.get("type", "") == "group_type":
|
|
245
243
|
report_data["sheet"].write_string(
|
|
246
244
|
report_data["row_pos"],
|
|
247
245
|
col_pos,
|
|
@@ -284,6 +282,8 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
284
282
|
value or "",
|
|
285
283
|
report_data["formats"]["format_right"],
|
|
286
284
|
)
|
|
285
|
+
else:
|
|
286
|
+
self.write_non_standard_column(cell_type, col_pos, value)
|
|
287
287
|
report_data["row_pos"] += 1
|
|
288
288
|
|
|
289
289
|
def write_initial_balance(self, my_object, label, report_data):
|
|
@@ -496,7 +496,7 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
496
496
|
report_data["formats"]["format_header_amount"],
|
|
497
497
|
)
|
|
498
498
|
elif cell_type == "amount_currency":
|
|
499
|
-
if my_object["currency_id"]
|
|
499
|
+
if my_object["currency_id"]:
|
|
500
500
|
format_amt = self._get_currency_amt_format_dict(
|
|
501
501
|
my_object, report_data
|
|
502
502
|
)
|
|
@@ -532,16 +532,17 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
532
532
|
format_amt = report_data["formats"]["format_amount"]
|
|
533
533
|
field_prefix = "format_amount"
|
|
534
534
|
if "currency_id" in line_object and line_object.get("currency_id", False):
|
|
535
|
-
|
|
535
|
+
if isinstance(line_object["currency_id"], int):
|
|
536
|
+
currency = self.env["res.currency"].browse(line_object["currency_id"])
|
|
537
|
+
else:
|
|
538
|
+
currency = line_object["currency_id"]
|
|
539
|
+
field_name = f"{field_prefix}_{currency.name}"
|
|
536
540
|
if hasattr(self, field_name):
|
|
537
541
|
format_amt = getattr(self, field_name)
|
|
538
542
|
else:
|
|
539
543
|
format_amt = report_data["workbook"].add_format()
|
|
540
544
|
report_data["field_name"] = format_amt
|
|
541
|
-
|
|
542
|
-
"0" * line_object["currency_id"].decimal_places
|
|
543
|
-
)
|
|
544
|
-
format_amt.set_num_format(format_amount)
|
|
545
|
+
format_amt.set_num_format(self._report_xlsx_currency_format(currency))
|
|
545
546
|
return format_amt
|
|
546
547
|
|
|
547
548
|
def _get_currency_amt_format_dict(self, line_dict, report_data):
|
|
@@ -557,21 +558,20 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
557
558
|
currency = self.env["res.currency"].browse(line_dict["currency_id"])
|
|
558
559
|
else:
|
|
559
560
|
currency = line_dict["currency_id"]
|
|
560
|
-
field_name = "{}_{
|
|
561
|
+
field_name = f"{field_prefix}_{currency.name}"
|
|
561
562
|
if hasattr(self, field_name):
|
|
562
563
|
format_amt = getattr(self, field_name)
|
|
563
564
|
else:
|
|
564
565
|
format_amt = report_data["workbook"].add_format()
|
|
565
566
|
report_data["field_name"] = format_amt
|
|
566
|
-
|
|
567
|
-
format_amt.set_num_format(format_amount)
|
|
567
|
+
format_amt.set_num_format(self._report_xlsx_currency_format(currency))
|
|
568
568
|
return format_amt
|
|
569
569
|
|
|
570
570
|
def _get_currency_amt_header_format(self, line_object, report_data):
|
|
571
571
|
"""Return amount header format for each currency."""
|
|
572
572
|
format_amt = report_data["formats"]["format_header_amount"]
|
|
573
573
|
if line_object.currency_id:
|
|
574
|
-
field_name = "format_header_amount_
|
|
574
|
+
field_name = f"format_header_amount_{line_object.currency_id.name}"
|
|
575
575
|
if hasattr(self, field_name):
|
|
576
576
|
format_amt = getattr(self, field_name)
|
|
577
577
|
else:
|
|
@@ -589,7 +589,7 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
589
589
|
"""Return amount header format for each currency."""
|
|
590
590
|
format_amt = report_data["formats"]["format_header_amount"]
|
|
591
591
|
if line_object["currency_id"]:
|
|
592
|
-
field_name = "format_header_amount_
|
|
592
|
+
field_name = f"format_header_amount_{line_object['currency_name']}"
|
|
593
593
|
if hasattr(self, field_name):
|
|
594
594
|
format_amt = getattr(self, field_name)
|
|
595
595
|
else:
|
|
@@ -597,9 +597,8 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
597
597
|
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
|
|
598
598
|
)
|
|
599
599
|
report_data["field_name"] = format_amt
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
)
|
|
600
|
+
currency = self.env["res.currency"].browse(line_object["currency_id"])
|
|
601
|
+
format_amount = "#,##0." + ("0" * currency.decimal_places)
|
|
603
602
|
format_amt.set_num_format(format_amount)
|
|
604
603
|
return format_amt
|
|
605
604
|
|
|
@@ -611,8 +610,8 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
611
610
|
|
|
612
611
|
def _get_report_complete_name(self, report, prefix, data=None):
|
|
613
612
|
if report.company_id:
|
|
614
|
-
suffix =
|
|
615
|
-
report.company_id.name
|
|
613
|
+
suffix = (
|
|
614
|
+
f" - {report.company_id.name} - {report.company_id.currency_id.name}"
|
|
616
615
|
)
|
|
617
616
|
return prefix + suffix
|
|
618
617
|
return prefix
|
|
@@ -690,3 +689,9 @@ class AbstractReportXslx(models.AbstractModel):
|
|
|
690
689
|
:return: the columns position used for final balance label.
|
|
691
690
|
"""
|
|
692
691
|
raise NotImplementedError()
|
|
692
|
+
|
|
693
|
+
def write_non_standard_column(self, cell_type, col_pos, value):
|
|
694
|
+
"""
|
|
695
|
+
Write columns out of the columns type defined here.
|
|
696
|
+
"""
|
|
697
|
+
raise NotImplementedError()
|
|
@@ -25,6 +25,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
25
25
|
ag_pb_data[acc_id]["90_days"] = 0.0
|
|
26
26
|
ag_pb_data[acc_id]["120_days"] = 0.0
|
|
27
27
|
ag_pb_data[acc_id]["older"] = 0.0
|
|
28
|
+
for interval_line in self.env.context["age_partner_config"].line_ids:
|
|
29
|
+
ag_pb_data[acc_id][interval_line] = 0.0
|
|
28
30
|
return ag_pb_data
|
|
29
31
|
|
|
30
32
|
@api.model
|
|
@@ -39,6 +41,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
39
41
|
ag_pb_data[acc_id][prt_id]["120_days"] = 0.0
|
|
40
42
|
ag_pb_data[acc_id][prt_id]["older"] = 0.0
|
|
41
43
|
ag_pb_data[acc_id][prt_id]["move_lines"] = []
|
|
44
|
+
for interval_line in self.env.context["age_partner_config"].line_ids:
|
|
45
|
+
ag_pb_data[acc_id][prt_id][interval_line] = 0.0
|
|
42
46
|
return ag_pb_data
|
|
43
47
|
|
|
44
48
|
@api.model
|
|
@@ -47,10 +51,12 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
47
51
|
):
|
|
48
52
|
ag_pb_data[acc_id]["residual"] += residual
|
|
49
53
|
ag_pb_data[acc_id][prt_id]["residual"] += residual
|
|
54
|
+
interval_lines = self.env.context["age_partner_config"].line_ids
|
|
50
55
|
today = date_at_object
|
|
51
56
|
if not due_date or today <= due_date:
|
|
52
57
|
ag_pb_data[acc_id]["current"] += residual
|
|
53
58
|
ag_pb_data[acc_id][prt_id]["current"] += residual
|
|
59
|
+
due_date = today
|
|
54
60
|
elif today <= due_date + timedelta(days=30):
|
|
55
61
|
ag_pb_data[acc_id]["30_days"] += residual
|
|
56
62
|
ag_pb_data[acc_id][prt_id]["30_days"] += residual
|
|
@@ -66,29 +72,73 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
66
72
|
else:
|
|
67
73
|
ag_pb_data[acc_id]["older"] += residual
|
|
68
74
|
ag_pb_data[acc_id][prt_id]["older"] += residual
|
|
75
|
+
|
|
76
|
+
days_difference = abs((today - due_date).days)
|
|
77
|
+
for index, line in enumerate(interval_lines):
|
|
78
|
+
lower_limit = 0 if not index else interval_lines[index - 1].inferior_limit
|
|
79
|
+
next_line = interval_lines[index] if index < len(interval_lines) else None
|
|
80
|
+
interval_range = self._get_values_for_range_intervals(
|
|
81
|
+
lower_limit, next_line.inferior_limit
|
|
82
|
+
)
|
|
83
|
+
if (
|
|
84
|
+
days_difference in interval_range
|
|
85
|
+
or days_difference == line.inferior_limit
|
|
86
|
+
):
|
|
87
|
+
ag_pb_data[acc_id][line] += residual
|
|
88
|
+
ag_pb_data[acc_id][prt_id][line] += residual
|
|
89
|
+
break
|
|
69
90
|
return ag_pb_data
|
|
70
91
|
|
|
92
|
+
def _get_values_for_range_intervals(self, num1, num2):
|
|
93
|
+
min_num = min(num1, num2)
|
|
94
|
+
max_num = max(num1, num2)
|
|
95
|
+
if abs(num2 - num1) == 1:
|
|
96
|
+
return [max_num]
|
|
97
|
+
return list(range(min_num + 1, max_num))
|
|
98
|
+
|
|
71
99
|
def _get_account_partial_reconciled(self, company_id, date_at_object):
|
|
72
100
|
domain = [("max_date", ">", date_at_object), ("company_id", "=", company_id)]
|
|
73
|
-
fields = [
|
|
101
|
+
fields = [
|
|
102
|
+
"debit_move_id",
|
|
103
|
+
"credit_move_id",
|
|
104
|
+
"amount",
|
|
105
|
+
"debit_amount_currency",
|
|
106
|
+
"credit_amount_currency",
|
|
107
|
+
]
|
|
74
108
|
accounts_partial_reconcile = self.env["account.partial.reconcile"].search_read(
|
|
75
109
|
domain=domain, fields=fields
|
|
76
110
|
)
|
|
77
111
|
debit_amount = {}
|
|
112
|
+
debit_amount_currency = {}
|
|
78
113
|
credit_amount = {}
|
|
114
|
+
credit_amount_currency = {}
|
|
79
115
|
for account_partial_reconcile_data in accounts_partial_reconcile:
|
|
80
116
|
debit_move_id = account_partial_reconcile_data["debit_move_id"][0]
|
|
81
117
|
credit_move_id = account_partial_reconcile_data["credit_move_id"][0]
|
|
82
118
|
if debit_move_id not in debit_amount.keys():
|
|
83
119
|
debit_amount[debit_move_id] = 0.0
|
|
120
|
+
debit_amount_currency[debit_move_id] = 0.0
|
|
121
|
+
debit_amount_currency[debit_move_id] += account_partial_reconcile_data[
|
|
122
|
+
"debit_amount_currency"
|
|
123
|
+
]
|
|
84
124
|
debit_amount[debit_move_id] += account_partial_reconcile_data["amount"]
|
|
85
125
|
if credit_move_id not in credit_amount.keys():
|
|
86
126
|
credit_amount[credit_move_id] = 0.0
|
|
127
|
+
credit_amount_currency[credit_move_id] = 0.0
|
|
87
128
|
credit_amount[credit_move_id] += account_partial_reconcile_data["amount"]
|
|
129
|
+
credit_amount_currency[credit_move_id] += account_partial_reconcile_data[
|
|
130
|
+
"credit_amount_currency"
|
|
131
|
+
]
|
|
88
132
|
account_partial_reconcile_data.update(
|
|
89
133
|
{"debit_move_id": debit_move_id, "credit_move_id": credit_move_id}
|
|
90
134
|
)
|
|
91
|
-
return
|
|
135
|
+
return (
|
|
136
|
+
accounts_partial_reconcile,
|
|
137
|
+
debit_amount,
|
|
138
|
+
credit_amount,
|
|
139
|
+
debit_amount_currency,
|
|
140
|
+
credit_amount_currency,
|
|
141
|
+
)
|
|
92
142
|
|
|
93
143
|
def _get_move_lines_data(
|
|
94
144
|
self,
|
|
@@ -103,19 +153,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
103
153
|
domain = self._get_move_lines_domain_not_reconciled(
|
|
104
154
|
company_id, account_ids, partner_ids, only_posted_moves, date_from
|
|
105
155
|
)
|
|
106
|
-
ml_fields =
|
|
107
|
-
"id",
|
|
108
|
-
"name",
|
|
109
|
-
"date",
|
|
110
|
-
"move_id",
|
|
111
|
-
"journal_id",
|
|
112
|
-
"account_id",
|
|
113
|
-
"partner_id",
|
|
114
|
-
"amount_residual",
|
|
115
|
-
"date_maturity",
|
|
116
|
-
"ref",
|
|
117
|
-
"reconciled",
|
|
118
|
-
]
|
|
156
|
+
ml_fields = self._get_ml_fields()
|
|
119
157
|
line_model = self.env["account.move.line"]
|
|
120
158
|
move_lines = line_model.search_read(domain=domain, fields=ml_fields)
|
|
121
159
|
journals_ids = set()
|
|
@@ -127,6 +165,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
127
165
|
acc_partial_rec,
|
|
128
166
|
debit_amount,
|
|
129
167
|
credit_amount,
|
|
168
|
+
debit_amount_currency,
|
|
169
|
+
credit_amount_currency,
|
|
130
170
|
) = self._get_account_partial_reconciled(company_id, date_at_object)
|
|
131
171
|
if acc_partial_rec:
|
|
132
172
|
ml_ids = list(map(operator.itemgetter("id"), move_lines))
|
|
@@ -147,6 +187,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
147
187
|
company_id,
|
|
148
188
|
partner_ids,
|
|
149
189
|
only_posted_moves,
|
|
190
|
+
debit_amount_currency,
|
|
191
|
+
credit_amount_currency,
|
|
150
192
|
)
|
|
151
193
|
move_lines = [
|
|
152
194
|
move_line
|
|
@@ -182,7 +224,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
182
224
|
elif not move_line["name"]:
|
|
183
225
|
ref_label = move_line["ref"]
|
|
184
226
|
else:
|
|
185
|
-
ref_label = move_line["ref"] +
|
|
227
|
+
ref_label = move_line["ref"] + " - " + move_line["name"]
|
|
186
228
|
move_line_data.update(
|
|
187
229
|
{
|
|
188
230
|
"line_rec": line_model.browse(move_line["id"]),
|
|
@@ -221,11 +263,15 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
221
263
|
"older": 0.0,
|
|
222
264
|
}
|
|
223
265
|
)
|
|
266
|
+
interval_lines = self.env.context["age_partner_config"].line_ids
|
|
267
|
+
for interval_line in interval_lines:
|
|
268
|
+
ml[interval_line] = 0.0
|
|
224
269
|
due_date = ml["due_date"]
|
|
225
270
|
amount = ml["residual"]
|
|
226
271
|
today = date_at_object
|
|
227
272
|
if not due_date or today <= due_date:
|
|
228
273
|
ml["current"] += amount
|
|
274
|
+
due_date = today
|
|
229
275
|
elif today <= due_date + timedelta(days=30):
|
|
230
276
|
ml["30_days"] += amount
|
|
231
277
|
elif today <= due_date + timedelta(days=60):
|
|
@@ -236,6 +282,24 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
236
282
|
ml["120_days"] += amount
|
|
237
283
|
else:
|
|
238
284
|
ml["older"] += amount
|
|
285
|
+
if due_date:
|
|
286
|
+
days_difference = abs((today - due_date).days)
|
|
287
|
+
for index, interval_line in enumerate(interval_lines):
|
|
288
|
+
lower_limit = (
|
|
289
|
+
0 if not index else interval_lines[index - 1].inferior_limit
|
|
290
|
+
)
|
|
291
|
+
next_line = (
|
|
292
|
+
interval_lines[index] if index < len(interval_lines) else None
|
|
293
|
+
)
|
|
294
|
+
interval_range = self._get_values_for_range_intervals(
|
|
295
|
+
lower_limit, next_line.inferior_limit
|
|
296
|
+
)
|
|
297
|
+
if (
|
|
298
|
+
days_difference in interval_range
|
|
299
|
+
or days_difference == interval_line.inferior_limit
|
|
300
|
+
):
|
|
301
|
+
ml[interval_line] += amount
|
|
302
|
+
break
|
|
239
303
|
|
|
240
304
|
def _create_account_list(
|
|
241
305
|
self,
|
|
@@ -247,6 +311,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
247
311
|
date_at_oject,
|
|
248
312
|
):
|
|
249
313
|
aged_partner_data = []
|
|
314
|
+
interval_lines = self.env.context["age_partner_config"].line_ids
|
|
250
315
|
for account in accounts_data.values():
|
|
251
316
|
acc_id = account["id"]
|
|
252
317
|
account.update(
|
|
@@ -261,6 +326,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
261
326
|
"partners": [],
|
|
262
327
|
}
|
|
263
328
|
)
|
|
329
|
+
for interval_line in interval_lines:
|
|
330
|
+
account[interval_line] = ag_pb_data[acc_id][interval_line]
|
|
264
331
|
for prt_id in ag_pb_data[acc_id]:
|
|
265
332
|
if isinstance(prt_id, int):
|
|
266
333
|
partner = {
|
|
@@ -273,6 +340,10 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
273
340
|
"120_days": ag_pb_data[acc_id][prt_id]["120_days"],
|
|
274
341
|
"older": ag_pb_data[acc_id][prt_id]["older"],
|
|
275
342
|
}
|
|
343
|
+
for interval_line in interval_lines:
|
|
344
|
+
partner[interval_line] = ag_pb_data[acc_id][prt_id][
|
|
345
|
+
interval_line
|
|
346
|
+
]
|
|
276
347
|
if show_move_line_details:
|
|
277
348
|
move_lines = []
|
|
278
349
|
for ml in ag_pb_data[acc_id][prt_id]["move_lines"]:
|
|
@@ -292,6 +363,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
292
363
|
|
|
293
364
|
@api.model
|
|
294
365
|
def _calculate_percent(self, aged_partner_data):
|
|
366
|
+
interval_lines = self.env.context["age_partner_config"].line_ids
|
|
295
367
|
for account in aged_partner_data:
|
|
296
368
|
if abs(account["residual"]) > 0.01:
|
|
297
369
|
total = account["residual"]
|
|
@@ -317,6 +389,10 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
317
389
|
),
|
|
318
390
|
}
|
|
319
391
|
)
|
|
392
|
+
for interval_line in interval_lines:
|
|
393
|
+
account[f"percent_{interval_line.id}"] = abs(
|
|
394
|
+
round((account[interval_line] / total) * 100, 2)
|
|
395
|
+
)
|
|
320
396
|
else:
|
|
321
397
|
account.update(
|
|
322
398
|
{
|
|
@@ -328,9 +404,12 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
328
404
|
"percent_older": 0.0,
|
|
329
405
|
}
|
|
330
406
|
)
|
|
407
|
+
for interval_line in interval_lines:
|
|
408
|
+
account[f"percent_{interval_line.id}"] = 0.0
|
|
331
409
|
return aged_partner_data
|
|
332
410
|
|
|
333
411
|
def _get_report_values(self, docids, data):
|
|
412
|
+
res = super()._get_report_values(docids, data)
|
|
334
413
|
wizard_id = data["wizard_id"]
|
|
335
414
|
company = self.env["res.company"].browse(data["company_id"])
|
|
336
415
|
company_id = data["company_id"]
|
|
@@ -341,12 +420,17 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
341
420
|
date_from = data["date_from"]
|
|
342
421
|
only_posted_moves = data["only_posted_moves"]
|
|
343
422
|
show_move_line_details = data["show_move_line_details"]
|
|
423
|
+
aged_partner_configuration = self.env[
|
|
424
|
+
"account.age.report.configuration"
|
|
425
|
+
].browse(data["age_partner_config_id"])
|
|
344
426
|
(
|
|
345
427
|
ag_pb_data,
|
|
346
428
|
accounts_data,
|
|
347
429
|
partners_data,
|
|
348
430
|
journals_data,
|
|
349
|
-
) = self.
|
|
431
|
+
) = self.with_context(
|
|
432
|
+
age_partner_config=aged_partner_configuration
|
|
433
|
+
)._get_move_lines_data(
|
|
350
434
|
company_id,
|
|
351
435
|
account_ids,
|
|
352
436
|
partner_ids,
|
|
@@ -355,7 +439,9 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
355
439
|
only_posted_moves,
|
|
356
440
|
show_move_line_details,
|
|
357
441
|
)
|
|
358
|
-
aged_partner_data = self.
|
|
442
|
+
aged_partner_data = self.with_context(
|
|
443
|
+
age_partner_config=aged_partner_configuration
|
|
444
|
+
)._create_account_list(
|
|
359
445
|
ag_pb_data,
|
|
360
446
|
accounts_data,
|
|
361
447
|
partners_data,
|
|
@@ -363,15 +449,30 @@ class AgedPartnerBalanceReport(models.AbstractModel):
|
|
|
363
449
|
show_move_line_details,
|
|
364
450
|
date_at_object,
|
|
365
451
|
)
|
|
366
|
-
aged_partner_data = self.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
452
|
+
aged_partner_data = self.with_context(
|
|
453
|
+
age_partner_config=aged_partner_configuration
|
|
454
|
+
)._calculate_percent(aged_partner_data)
|
|
455
|
+
res.update(
|
|
456
|
+
{
|
|
457
|
+
"doc_ids": [wizard_id],
|
|
458
|
+
"doc_model": "aged.partner.balance.report.wizard",
|
|
459
|
+
"docs": self.env["aged.partner.balance.report.wizard"].browse(
|
|
460
|
+
wizard_id
|
|
461
|
+
),
|
|
462
|
+
"company_name": company.display_name,
|
|
463
|
+
"currency_name": company.currency_id.name,
|
|
464
|
+
"date_at": date_at,
|
|
465
|
+
"only_posted_moves": only_posted_moves,
|
|
466
|
+
"aged_partner_balance": aged_partner_data,
|
|
467
|
+
"show_move_lines_details": show_move_line_details,
|
|
468
|
+
"age_partner_config": aged_partner_configuration,
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
return res
|
|
472
|
+
|
|
473
|
+
def _get_ml_fields(self):
|
|
474
|
+
return self.COMMON_ML_FIELDS + [
|
|
475
|
+
"amount_residual",
|
|
476
|
+
"reconciled",
|
|
477
|
+
"date_maturity",
|
|
478
|
+
]
|