[IMP] account: use float_compare for taxes

Avoiding some python float representation errors
This commit is contained in:
Martin Trigaux 2014-09-26 16:55:41 +02:00
parent cac6a261fe
commit ceff8ef899
1 changed files with 3 additions and 1 deletions

View File

@ -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: