X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Fproduct%2Fproduct.py;h=e5afb4ef38d4b1ea2b97ac1da57f8f90febbd3cd;hb=c255fe33846f5b61134775d87270cd0135a514a9;hp=2b70e1a3101e3d49b10d14b6229b3947666a60c3;hpb=49c8fc21baa806cab4631f58caa487f4b75f9996;p=odoo%2Fodoo.git diff --git a/addons/product/product.py b/addons/product/product.py index 2b70e1a..e5afb4e 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -156,13 +156,14 @@ class product_uom(osv.osv): 'rounding': 0.01, 'factor': 1, 'uom_type': 'reference', + 'factor': 1.0, } _sql_constraints = [ ('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!') ] - def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False, round=True): + def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False, round=True, rounding_method='UP'): if not from_uom_id or not qty or not to_uom_id: return qty uoms = self.browse(cr, uid, [from_uom_id, to_uom_id]) @@ -170,9 +171,9 @@ class product_uom(osv.osv): from_unit, to_unit = uoms[0], uoms[-1] else: from_unit, to_unit = uoms[-1], uoms[0] - return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit, round=round) + return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit, round=round, rounding_method=rounding_method) - def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, round=True, context=None): + def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, round=True, rounding_method='UP', context=None): if context is None: context = {} if from_unit.category_id.id != to_unit.category_id.id: @@ -184,7 +185,7 @@ class product_uom(osv.osv): if to_unit: amount = amount * to_unit.factor if round: - amount = ceiling(amount, to_unit.rounding) + amount = float_round(amount, precision_rounding=to_unit.rounding, rounding_method=rounding_method) return amount def _compute_price(self, cr, uid, from_uom_id, price, to_uom_id=False):