[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
This commit is contained in:
@@ -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
|
||||
####################################################
|
||||
|
||||
Reference in New Issue
Block a user