From eaf53213da2ba6bb0e620d8eadc58e33016e2aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?= Date: Fri, 26 Oct 2012 11:12:42 +0200 Subject: [PATCH] [IMP] Forbid the user to delete any move linked to an invoice. Cancelling invoice still work obviously bzr revid: joel.grandguillaume@camptocamp.com-20121026091242-9fu2a4do0ra50fqu --- addons/account/account.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/account/account.py b/addons/account/account.py index f3ba38fee8d..330e3f2d742 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1485,6 +1485,11 @@ class account_move(osv.osv): raise osv.except_osv(_('User Error!'), _('You cannot delete a posted journal entry "%s".') % \ move['name']) + for line in move.line_id: + if line.invoice: + raise osv.except_osv(_('User Error!'), + _("Move cannot be deleted if linked to an invoice: %s : Move ID:%s.") % \ + (line.invoice.number,move.name)) line_ids = map(lambda x: x.id, move.line_id) context['journal_id'] = move.journal_id.id context['period_id'] = move.period_id.id