Add warning when deleting account reconciliation with write-off line

Closes #4685
This commit is contained in:
Cédric Krier
2023-02-15 23:08:53 +01:00
parent 4c38035419
commit 6457bc5ca1
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -149,6 +149,10 @@ Use the current period to cancel the move?</field>
</record>
<record model="ir.message" id="msg_reconciliation_delete_delegated">
<field name="text">The reconciliation "%(reconciliation)s" is delegated to the line "%(line)s".
You may need to cancel its move "%(move)s".</field>
</record>
<record model="ir.message" id="msg_reconciliation_delete_write_off">
<field name="text">The reconciliation "%(reconciliation)s" is linked to the write-off line "%(line)s".
You may need to cancel its move "%(move)s".</field>
</record>
<record model="ir.message" id="msg_reconciliation_line_not_valid">
+10
View File
@@ -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