From db4c87ffbc5e6b618ffe8acce28726f31ce2ca5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 9 May 2014 23:33:02 +0200 Subject: [PATCH] Use cancel of Account Move issue3875 review10261002 --- invoice.py | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/invoice.py b/invoice.py index f0c334f10c..e7ffc1378c 100644 --- a/invoice.py +++ b/invoice.py @@ -208,9 +208,6 @@ class Invoice(Workflow, ModelSQL, ModelView): 'customer_invoice_cancel_move': ( 'Customer invoice/credit note ' '"%s" can not be cancelled once posted.'), - 'period_cancel_move': ( - 'The period of Invoice "%s" is closed.\n' - 'Use the today for cancel move?'), }) cls._transitions |= set(( ('draft', 'validated'), @@ -1373,34 +1370,6 @@ class Invoice(Workflow, ModelSQL, ModelView): def paid(cls, invoices): pass - def get_cancel_move(self): - pool = Pool() - Date = pool.get('ir.date') - Move = pool.get('account.move') - Period = pool.get('account.period') - - move = self.move - default = {} - if move.period.state == 'close': - self.raise_user_warning('%s.get_cancel_move' % self, - 'period_cancel_move', self.rec_name) - date = Date.today() - period_id = Period.find(self.company.id, date=date) - default.update({ - 'date': date, - 'period': period_id, - }) - - cancel_move, = Move.copy([move], default=default) - for line in cancel_move.lines: - line.debit *= -1 - line.credit *= -1 - line.save() - for tax_line in line.tax_lines: - tax_line.amount *= -1 - tax_line.save() - return cancel_move - @classmethod @ModelView.button @Workflow.transition('cancel') @@ -1416,7 +1385,7 @@ class Invoice(Workflow, ModelSQL, ModelView): if invoice.move.state == 'draft': delete_moves.append(invoice.move) elif not invoice.cancel_move: - invoice.cancel_move = invoice.get_cancel_move() + invoice.cancel_move = invoice.move.cancel() invoice.save() cancel_moves.append(invoice.cancel_move) if delete_moves: