From 6b9040ca8d0be10f1aa65078e0e9da1776c07211 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 13 Oct 2009 16:34:10 +0200 Subject: [PATCH] [FIX] account: avoid ZeroDivisionError bzr revid: chs@tinyerp.com-20091013143410-sz59hp38dvv1ufor --- addons/account/invoice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 10a54e8bb37..10a49230480 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -115,7 +115,10 @@ class account_invoice(osv.osv): else: debit += lines.debit credit += lines.credit - if inv.type in ('out_invoice','in_refund'): + + if not inv.amount_total: + result = 0.0 + elif inv.type in ('out_invoice','in_refund'): result = inv.amount_total * (1.0 - credit / (debit + inv.amount_total)) else: result = inv.amount_total * (1.0 - debit / (credit + inv.amount_total))