From e85fb22bd5e0702133fc9aba6fd34556eafbbc0a Mon Sep 17 00:00:00 2001 From: Jon Erik Ceberio Date: Fri, 18 Feb 2022 15:28:06 +0100 Subject: [PATCH] [FIX] account_reconciliation_widget: in case of manual operation with analytic account/tags, create the analytic entry(ies) if the move is posted --- .../models/account_bank_statement.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/account_reconciliation_widget/models/account_bank_statement.py b/account_reconciliation_widget/models/account_bank_statement.py index b654ca11..b8267942 100644 --- a/account_reconciliation_widget/models/account_bank_statement.py +++ b/account_reconciliation_widget/models/account_bank_statement.py @@ -234,8 +234,12 @@ class AccountBankStatementLine(models.Model): self._prepare_move_line_for_currency(aml_dict, date) # Create write-offs + wo_aml = self.env["account.move.line"] for aml_dict in new_aml_dicts: - aml_obj.with_context(check_move_validity=False).create(aml_dict) + wo_aml |= aml_obj.with_context(check_move_validity=False).create(aml_dict) + analytic_wo_aml = wo_aml.filtered( + lambda l: l.analytic_account_id or l.analytic_tag_ids + ) # Create counterpart move lines and reconcile them aml_to_reconcile = [] @@ -259,6 +263,9 @@ class AccountBankStatementLine(models.Model): self.move_id.with_context( skip_account_move_synchronization=True ).action_post() + elif analytic_wo_aml: + # if already posted the analytic entry has to be created + analytic_wo_aml.create_analytic_lines() # Reconcile new lines with counterpart for new_aml, counterpart_move_line in aml_to_reconcile: