[FIX] account: don't overwrite statement_line_id when reconciling transfer account

Description of the issue:

Transfer between Bank1 (550001) and Bank 2 (550002) of the same company via the intercompany bank account (580000) :

Bank 1: minus 1000 EUR, we create the following accounting entry via the reconcile widget

account 550001 credit 1000
account 580000 debit 1000

Bank 2 : Plus 1000 EUR

When we select the counterparty 580000 entry of the Bank 1 statement via the reconcile widget
than the statement_line_id of the entry from Bank 1 statement is replaced by the one of the Bank 2 statement.
Hence this account.move.line is linked to the wrong statement line.

closes odoo/odoo#43371

X-original-commit: 3d74e7397e15311f1e9189589a435d9683376317
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
Luc De Meyer
2020-01-15 16:36:27 +00:00
parent b239201190
commit f08204c69c
@@ -852,7 +852,7 @@ class AccountBankStatementLine(models.Model):
# Create counterpart move lines and reconcile them
for aml_dict in counterpart_aml_dicts:
if aml_dict['move_line'].payment_id:
if aml_dict['move_line'].payment_id and not aml_dict['move_line'].statement_line_id:
aml_dict['move_line'].write({'statement_line_id': self.id})
if aml_dict['move_line'].partner_id.id:
aml_dict['partner_id'] = aml_dict['move_line'].partner_id.id