From ceff8ef8992b598d44e95ed349dc63b2d6c6b5c1 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 26 Sep 2014 16:55:41 +0200 Subject: [PATCH] [IMP] account: use float_compare for taxes Avoiding some python float representation errors --- addons/account/account_invoice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 1e4bc7ad230..9baa3f76342 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -27,6 +27,7 @@ import openerp.exceptions from openerp import netsvc, SUPERUSER_ID from openerp import pooler from openerp.osv import fields, osv, orm +from openerp.tools import float_compare from openerp.tools.translate import _ class account_invoice(osv.osv): @@ -826,7 +827,8 @@ class account_invoice(osv.osv): if not key in compute_taxes: raise osv.except_osv(_('Warning!'), _('Global taxes defined, but they are not in invoice lines !')) base = compute_taxes[key]['base'] - if abs(base - tax.base) > company_currency.rounding: + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') + if float_compare(abs(base - tax.base), company_currency.rounding, precision_rounding=precision) == 1: raise osv.except_osv(_('Warning!'), _('Tax base different!\nClick on compute to update the tax base.')) for key in compute_taxes: if not key in tax_key: