From 2f66e77fe8f46ace6eee1bcf306c453c1b3ce949 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 21 Feb 2017 17:25:02 +0100 Subject: [PATCH] [FIX] account: variable `st_line` used outside its scope The variable `st_line` was used outside of its scope, in the line `move.line_ids.filtered(lambda x:x.statement_id == st_line.statement_id).write({'statement_id': False})` It leaded to issues when calling the method on multiple `account.bank.statement.line`: Only the items associated to the last line were unlinked opw-709196 --- addons/account/models/account_bank_statement.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 871f4f9ebd7..a3f1544987e 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -418,21 +418,20 @@ class AccountBankStatementLine(models.Model): @api.multi def button_cancel_reconciliation(self): - moves_to_unbind = self.env['account.move'] moves_to_cancel = self.env['account.move'] payment_to_unreconcile = self.env['account.payment'] for st_line in self: - moves_to_unbind |= st_line.journal_entry_ids + moves_to_unbind = st_line.journal_entry_ids for move in st_line.journal_entry_ids: if any(line.payment_id for line in move.line_ids): for line in move.line_ids: payment_to_unreconcile |= line.payment_id continue moves_to_cancel |= st_line.journal_entry_ids - if moves_to_unbind: - moves_to_unbind.write({'statement_line_id': False}) - for move in moves_to_unbind: - move.line_ids.filtered(lambda x:x.statement_id == st_line.statement_id).write({'statement_id': False}) + if moves_to_unbind: + moves_to_unbind.write({'statement_line_id': False}) + for move in moves_to_unbind: + move.line_ids.filtered(lambda x:x.statement_id == st_line.statement_id).write({'statement_id': False}) if moves_to_cancel: for move in moves_to_cancel: