From 6457bc5ca16834757b8f37b3357bf6ced9cc4bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 15 Feb 2023 23:08:53 +0100 Subject: [PATCH] Add warning when deleting account reconciliation with write-off line Closes #4685 --- modules/account/message.xml | 4 ++++ modules/account/move.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/modules/account/message.xml b/modules/account/message.xml index 53df826188..2e770939e8 100644 --- a/modules/account/message.xml +++ b/modules/account/message.xml @@ -149,6 +149,10 @@ Use the current period to cancel the move? The reconciliation "%(reconciliation)s" is delegated to the line "%(line)s". +You may need to cancel its move "%(move)s". + + + The reconciliation "%(reconciliation)s" is linked to the write-off line "%(line)s". You may need to cancel its move "%(move)s". diff --git a/modules/account/move.py b/modules/account/move.py index 52af7d8a92..7d55b87139 100644 --- a/modules/account/move.py +++ b/modules/account/move.py @@ -609,6 +609,16 @@ class Reconciliation(ModelSQL, ModelView): reconciliation=reconciliation.rec_name, line=reconciliation.delegate_to.rec_name, move=reconciliation.delegate_to.move.rec_name)) + for line in reconciliation.lines: + if line.move.journal.type == 'write-off': + key = Warning.format('delete.write-off', [reconciliation]) + if Warning.check(key): + raise ReconciliationDeleteWarning(key, + gettext( + 'account.msg_reconciliation_delete_write_off', + reconciliation=reconciliation.rec_name, + line=line.rec_name, + move=line.move.rec_name)) super().delete(reconciliations) @classmethod