diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 46f36142090..d95a76f610a 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -98,9 +98,10 @@ class purchase_order(osv.osv): tot = 0.0 for invoice in purchase.invoice_ids: if invoice.state not in ('draft','cancel'): - tot += invoice.amount_untaxed - invoice.residual + tot += invoice.amount_untaxed + if purchase.amount_untaxed: - res[purchase.id] = tot * 100.0 / purchase.amount_untaxed + res[purchase.id] = min(100.0, tot * 100.0 / (purchase.amount_untaxed)) else: res[purchase.id] = 0.0 return res diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 2b218f7e5cf..6e64c6589e9 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -131,7 +131,7 @@ class sale_order(osv.osv): tot = 0.0 for invoice in sale.invoice_ids: if invoice.state not in ('draft', 'cancel'): - tot += invoice.amount_untaxed - invoice.residual + tot += invoice.amount_untaxed if tot: res[sale.id] = min(100.0, tot * 100.0 / (sale.amount_untaxed or 1.00)) else: