diff --git a/account_financial_report/__manifest__.py b/account_financial_report/__manifest__.py index 2c1c23049d00..78a778d95611 100644 --- a/account_financial_report/__manifest__.py +++ b/account_financial_report/__manifest__.py @@ -6,7 +6,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Account Financial Reports", - "version": "16.0.1.5.4", + "version": "16.0.1.9.0, "category": "Reporting", "summary": "OCA Financial Reports", "author": "Camptocamp SA," diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index 1dfb200fa6d9..7f1347a494bd 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -764,6 +764,29 @@ def _get_centralized_ml(self, account, date_to, grouped_by): list_centralized_ml += list(centralized_ml[jnl_id].values()) return list_centralized_ml + @api.model + def _get_joined_entries_ml(self, account): + ml = {} + for entry in account.get("move_lines", []): + entry_id = entry["entry_id"] + if not ml.get(entry_id, False): + ml[entry_id] = entry + else: + if not ml[entry_id].get("is_joined_entry", False): + ml[entry_id]["is_joined_entry"] = True + ml[entry_id]["name"] = self.env["account.move"].browse( + entry["entry_id"]).name + ml[entry_id]["ref_label"] = ml[entry_id]["ref"] + ml[entry_id]["id"] = None + ml[entry_id]["balance"] += (entry["debit"] - entry["credit"]) + ml[entry_id]["bal_curr"] += entry["bal_curr"] + ml[entry_id]["credit"] += entry["credit"] + ml[entry_id]["debit"] += entry["debit"] + ml[entry_id]["tax_ids"] += entry["tax_ids"] + ml[entry_id]["tax_ids"] = list(set(ml[entry_id]["tax_ids"])) + # filtered_ml = {k: v for k, v in ml.items() if v["name"] == "Joined Entries"} + return list(ml.values()) + def _get_report_values(self, docids, data): wizard_id = data["wizard_id"] company = self.env["res.company"].browse(data["company_id"]) @@ -780,6 +803,8 @@ def _get_report_values(self, docids, data): unaffected_earnings_account = data["unaffected_earnings_account"] fy_start_date = data["fy_start_date"] extra_domain = data["domain"] + join_entry_ml = data["join_entry_ml"] + hide_rows_at_0 = data["hide_rows_at_0"] gen_ld_data = self._get_initial_balance_data( account_ids, partner_ids, @@ -837,6 +862,15 @@ def _get_report_values(self, docids, data): if grouped_by and account[grouped_by]: account[grouped_by] = False del account["list_grouped"] + elif join_entry_ml: + for account in general_ledger: + if account.get("move_lines", []): + joined_entries_ml = self._get_joined_entries_ml(account) + account["move_lines"] = joined_entries_ml + if grouped_by and account[grouped_by]: + for item in account.get("list_grouped", []): + joined_entries_ml = self._get_joined_entries_ml(item) + item["move_lines"] = joined_entries_ml general_ledger = sorted(general_ledger, key=lambda k: k["code"]) return { "doc_ids": [wizard_id], @@ -860,6 +894,7 @@ def _get_report_values(self, docids, data): "analytic_data": analytic_data, "filter_partner_ids": True if partner_ids else False, "currency_model": self.env["res.currency"], + "hide_rows_at_0": hide_rows_at_0, } def _get_ml_fields(self): diff --git a/account_financial_report/report/templates/general_ledger.xml b/account_financial_report/report/templates/general_ledger.xml index 7bcfa4120b34..863754203406 100644 --- a/account_financial_report/report/templates/general_ledger.xml +++ b/account_financial_report/report/templates/general_ledger.xml @@ -371,7 +371,16 @@ t-set="total_bal_curr" t-value="account_or_group_item_object['init_bal'].get('bal_curr', 0)" /> - + + + + + + + + + +
@@ -389,6 +398,19 @@ /> + + + + + + @@ -469,6 +491,15 @@ + + + + + @@ -541,6 +572,18 @@ /> + + + + + + + + + + + + + + + + +