[FIX] Account : Validation should not throw sero division error
authorJMA(OpenERP) <>
Wed, 20 Oct 2010 13:58:03 +0000 (19:28 +0530)
committerJay (OpenERP) <jvo@tinyerp.com>
Wed, 20 Oct 2010 13:58:03 +0000 (19:28 +0530)
lp bug: https://launchpad.net/bugs/663402 fixed

bzr revid: jvo@tinyerp.com-20101020135803-m4wyc0uk32aulv6f

addons/account/invoice.py

index ab9b90d..dbac0fd 100644 (file)
@@ -830,7 +830,7 @@ class account_invoice(osv.osv):
                         total_fixed += line.value_amount
                     if line.value == 'procent':
                         total_percent += line.value_amount
-                total_fixed = (total_fixed * 100) / inv.amount_total
+                total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0)
                 if (total_fixed + total_percent) > 100:
                     raise osv.except_osv(_('Error !'), _("Cannot create the invoice !\nThe payment term defined gives a computed amount greater than the total invoiced amount."))