[FIX] account: fix statement_line_id on bank statement processing.

Since ee2c76a431, a new field 'statement_line_id' has been added on account.move.line object and the field 'statement_id' became a related... but this statement_line_id on the bank account aml was, by mistake, not set. That created aml that were wrongly appearing in blue in the reconciliation widget.

If this error occured in a DB, the following SQL query can fix it:
$ UPDATE account_move_line l SET statement_line_id = s.id FROM account_bank_statement_line s
   WHERE l.statement_line_id IS NULL
   AND l.statement_id = s.statement_id
   AND l.name = s.name
   AND coalesce(s.partner_id, 0) = coalesce(l.partner_id, 0);
This commit is contained in:
qdp-odoo
2017-03-29 13:55:14 +02:00
parent 79975f7cec
commit 26938da071
@@ -787,7 +787,7 @@ class AccountBankStatementLine(models.Model):
or self.statement_id.journal_id.default_debit_account_id.id,
'credit': amount < 0 and -amount or 0.0,
'debit': amount > 0 and amount or 0.0,
'statement_id': self.statement_id.id,
'statement_line_id': self.id,
'currency_id': statement_currency != company_currency and statement_currency.id or (st_line_currency != company_currency and st_line_currency.id or False),
'amount_currency': amount_currency,
}