From 060e35f62adae0795f325ab6cc9019d87fb2412e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Sat, 11 May 2019 16:17:24 +0000 Subject: [PATCH] [FIX] account: allow cancelling payment whith draft move Payment journals have an option to keep moves unposted until bank statement reconciliation. When cancelling such payments, it is not necessary to attempt canceling the move if it is unposted. This patch allows cancelling such payments without needing to configure the journal as cancellable while the move is still draft. To reproduce: 1. check "Post at bank reconciliation" on a bank journal 2. do "Register payment" with that journal on a invoice 3. open the generated payment 4. click cancel => error "You cannot modify a posted entry of this journal..." closes odoo/odoo#33312 Signed-off-by: Laurent Smet --- addons/account/models/account_payment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 0dd087aee42..506f3885e89 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -601,7 +601,8 @@ class account_payment(models.Model): for move in rec.move_line_ids.mapped('move_id'): if rec.invoice_ids: move.line_ids.remove_move_reconcile() - move.button_cancel() + if move.state != 'draft': + move.button_cancel() move.unlink() rec.write({ 'state': 'cancelled',