Merge PR #444 into 14.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2023-02-07 19:04:01 +00:00

View File

@@ -234,8 +234,12 @@ class AccountBankStatementLine(models.Model):
self._prepare_move_line_for_currency(aml_dict, date) self._prepare_move_line_for_currency(aml_dict, date)
# Create write-offs # Create write-offs
wo_aml = self.env["account.move.line"]
for aml_dict in new_aml_dicts: 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 # Create counterpart move lines and reconcile them
aml_to_reconcile = [] aml_to_reconcile = []
@@ -259,6 +263,9 @@ class AccountBankStatementLine(models.Model):
self.move_id.with_context( self.move_id.with_context(
skip_account_move_synchronization=True skip_account_move_synchronization=True
).action_post() ).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 # Reconcile new lines with counterpart
for new_aml, counterpart_move_line in aml_to_reconcile: for new_aml, counterpart_move_line in aml_to_reconcile: