From fad2dc8ac4bda5efb49ae69fe27396eb0cebf20a Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 16 Jun 2016 10:27:03 +0200 Subject: [PATCH] [FIX] account: statement line reconciliation cancel On the cancelation of a bank statement line reconciled with journal items created by the registering a payment, in addition to unbind the move with the statement line, the statement must be unbind from the move, and the payment must be reset to posted. opw-680128 --- addons/account/models/account_bank_statement.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 367fbc13800..562102cf869 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -421,20 +421,28 @@ class AccountBankStatementLine(models.Model): 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 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}) + moves_to_unbind.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: move.line_ids.remove_move_reconcile() moves_to_cancel.button_cancel() moves_to_cancel.unlink() + if payment_to_unreconcile: + payment_to_unreconcile.write({'state': 'posted'}) + #################################################### # Reconciliation interface methods ####################################################