[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
This commit is contained in:
Joël Grand-Guillaume 2012-10-26 11:12:42 +02:00
parent 8132259454
commit eaf53213da
1 changed files with 5 additions and 0 deletions

View File

@ -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