Add warning when deleting account reconciliation with write-off line
Closes #4685
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user