diff --git a/addons/product/_common.py b/addons/product/_common.py index f5f53fe8689..def09e975af 100644 --- a/addons/product/_common.py +++ b/addons/product/_common.py @@ -18,12 +18,20 @@ # along with this program. If not, see . # ############################################################################## +from openerp import tools + +import math +import logging +_logger = logging.getLogger(__name__) + + def rounding(f, r): + # TODO for trunk: log deprecation warning + # _logger.warning("Deprecated rounding method, please use tools.float_round to round floats.") + return tools.float_round(f, precision_rounding=r) + +# TODO for trunk: add rounding method parameter to tools.float_round and remove this method +def ceiling(f, r): if not r: return f - return round(f / r) * r - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - + return math.ceil(f / r) * r diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 426931f9a27..86480c60059 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -21,7 +21,7 @@ import time -from _common import rounding +from _common import ceiling from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -296,7 +296,7 @@ class product_pricelist(osv.osv): if price is not False: price_limit = price price = price * (1.0+(res['price_discount'] or 0.0)) - price = rounding(price, res['price_round']) #TOFIX: rounding with tools.float_rouding + price = ceiling(price, res['price_round']) price += (res['price_surcharge'] or 0.0) if res['price_min_margin']: price = max(price, price_limit+res['price_min_margin']) diff --git a/addons/product/product.py b/addons/product/product.py index d9419fc4d68..34503b5136e 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -22,7 +22,7 @@ import math import re -from _common import rounding +from _common import ceiling from openerp import tools from openerp.osv import osv, fields @@ -178,7 +178,7 @@ class product_uom(osv.osv): return qty amount = qty / from_unit.factor if to_unit: - amount = rounding(amount * to_unit.factor, to_unit.rounding) + amount = ceiling(amount * to_unit.factor, to_unit.rounding) return amount def _compute_price(self, cr, uid, from_uom_id, price, to_uom_id=False):