[FIX] account: statement line reconciliation cancel
Cancelling a statement line should not remove the according journal items if they are associated to an `account.payment`. In this case, this should simply remove the `statement_id` of the move lines, and unmark the `account.payment` as reconciled. opw-674896
This commit is contained in:
@@ -419,17 +419,21 @@ class AccountBankStatementLine(models.Model):
|
||||
|
||||
@api.multi
|
||||
def button_cancel_reconciliation(self):
|
||||
# TOCKECK : might not behave as expected in case of reconciliations (match statement line with already
|
||||
# registered payment) or partial reconciliations : it will completely remove the existing payment.
|
||||
move_recs = self.env['account.move']
|
||||
moves_to_unbind = self.env['account.move']
|
||||
moves_to_cancel = self.env['account.move']
|
||||
for st_line in self:
|
||||
move_recs = (move_recs | st_line.journal_entry_ids)
|
||||
if move_recs:
|
||||
for move in move_recs:
|
||||
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):
|
||||
continue
|
||||
moves_to_cancel |= st_line.journal_entry_ids
|
||||
if moves_to_unbind:
|
||||
moves_to_unbind.write({'statement_line_id': False})
|
||||
if moves_to_cancel:
|
||||
for move in moves_to_cancel:
|
||||
move.line_ids.remove_move_reconcile()
|
||||
move_recs.write({'statement_line_id': False})
|
||||
move_recs.button_cancel()
|
||||
move_recs.unlink()
|
||||
moves_to_cancel.button_cancel()
|
||||
moves_to_cancel.unlink()
|
||||
|
||||
####################################################
|
||||
# Reconciliation interface methods
|
||||
|
||||
Reference in New Issue
Block a user