From ca720de9ec6a51dba7557a84e70a428a1346e97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 4 Dec 2008 15:37:26 +0100 Subject: [PATCH] Invert debit/credit for invoice line move with negative amount --- invoice.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/invoice.py b/invoice.py index d45ef49aea..d0b47ca336 100644 --- a/invoice.py +++ b/invoice.py @@ -1699,12 +1699,21 @@ class InvoiceLine(OSV): res['amount_second_currency'] = Decimal('0.0') res['second_currency'] = False if line.invoice.type in ('in_invoice', 'out_credit_note'): - res['debit'] = amount - res['credit'] = Decimal('0.0') + if amount >= Decimal('0.0'): + res['debit'] = amount + res['credit'] = Decimal('0.0') + else: + res['debit'] = Decimal('0.0') + res['credit'] = - amount + res['amount_second_currency'] = - res['amount_second_currency'] else: - res['debit'] = Decimal('0.0') - res['credit'] = amount - res['amount_second_currency'] = - res['amount_second_currency'] + if amount >= Decimal('0.0'): + res['debit'] = Decimal('0.0') + res['credit'] = amount + res['amount_second_currency'] = - res['amount_second_currency'] + else: + res['debit'] = - amount + res['credit'] = Decimal('0.0') res['account'] = line.account.id res['party'] = line.invoice.party.id computed_taxes = self._compute_taxes(cursor, user, line,