Commit Graph

15 Commits

Author SHA1 Message Date
Martin Trigaux 7705f883d2 [FIX] base: support float rounding with rounding_method=UP (ceiling)
Add rounding_method parameter on float_round method to offer
HALF-UP (default, usual round) or UP (ceiling) rounding method.
Use the second method instead of math.ceil() for product
reservations.

For UP, the python math.ceil() method uses "torwards infinity"
rounding method while we want "away from zero".
Therefore we use the absolute value of normalized_value to make
sure than -1.8 is rounded to -2.0 and not -1.

Fixes #1125 #2793

This is a cherry-pick of d4972ff which was reverted at 333852e due
to remaining issue with negative values.
2014-10-22 14:28:22 +02:00
Denis Ledoux 333852e19d Revert "[FIX] product,float_utils: perform ceiling via float_round with new rounding_method UP"
This reverts commit d4972ffdb6.

Seems to break some cases, at least in _product_reserve from stock/stock.py

Actual use case:

SELECT product_uom, sum(product_qty) AS product_qty FROM stock_move WHERE location_dest_id=%s AND location_id<>%s AND product_id=3645 AND state='done' GROUP BY product_uom;
returning 1 | 6

SELECT product_uom,-sum(product_qty) AS product_qty FROM stock_move WHERE location_id=%s AND location_dest_id<>%s AND product_id=%s AND state in ('done', 'assigned') GROUP BY product_uom;
returning 1 | -6

results += cr.dictfetchall()
    total = 0.0
    results2 = 0.0
    for r in results:
        amount = uom_obj._compute_qty(cr, uid, r['product_uom'], r['product_qty'], context.get('uom', False))
        results2 += amount
        total += amount
Total = 1, amount = -5

It should actually be
Total = 0, amount = -6
2014-09-26 21:21:06 +02:00
Cedric Snauwaert d4972ffdb6 [FIX] product,float_utils: perform ceiling via float_round with new rounding_method UP
Modified product ceiling() to use float_round() with special mode
for rounding UP (away from zero), avoiding pathological cases where
float representations errors were ceiling to the superior unit.

Also added correspding tests for rounding_method=UP

Fixes issue #1125, and replaces PR #1126.
2014-09-24 17:11:25 +02:00
Martin Trigaux 1e048736df [IMP] remove useless imports
bzr revid: mat@openerp.com-20140306153125-czwswqw1k3w5ungh
2014-03-06 16:31:25 +01:00
Martin Trigaux 5db649549c [IMP] mrp: use also the ceiling method from product
bzr revid: mat@openerp.com-20140306094504-37r691hxcemp0ual
2014-03-06 10:45:04 +01:00
Martin Trigaux 1967b6ce19 [FIX] product: when converting unit of mesures, round above instead of mathematical rounding
bzr revid: mat@openerp.com-20140305171456-goo7on3ncfihu0wu
2014-03-05 18:14:56 +01:00
Stephane Wirtel fb3ef7a2f4 [FIX] Change the year of the copyright
bzr revid: stephane@openerp.com-20100112091839-a6p7tenhb4e4zxyx
2010-01-12 10:18:39 +01:00
PSO(OpenERP) eb0b928cc0 Changed licencing terms
bzr revid: hda@tinyerp.com-20091014111534-1vtk21rz8byhszzf
2009-10-14 16:45:34 +05:30
ChristopheChauvet(syleam) 41e8ed59ef changed encoding to coding in all py files
lp bug: https://launchpad.net/bugs/357182 fixed

bzr revid: hda@tinyerp.com-20091013055837-3ntnbe8b938xmk97
2009-10-13 11:28:37 +05:30
Stephane Wirtel 21f104a506 [IMP] Update the copyright to 2009
bzr revid: stephane@tinyerp.com-20090104221250-55q32ayj2t8kzb2k
2009-01-04 23:12:50 +01:00
Christophe Simonis f5fad0ba30 passing modules in GPL-3
bzr revid: christophe@tinyerp.com-20081103191856-jhcivvwb16fvz2os
2008-11-03 20:18:56 +01:00
Christophe Simonis 3e3d897e88 add encoding comment and vim comment
bzr revid: christophe@tinyerp.com-20080723144147-77o5t9adx26a84lt
2008-07-23 16:41:47 +02:00
Christophe Simonis d2ff95f665 replace tabs with 4 spaces
bzr revid: christophe@tinyerp.com-20080722151128-f5zy75tsn8pgtndd
2008-07-22 17:11:28 +02:00
stw 0feb782c6a add Copyright and GPL license into the Header of Python files
bzr revid: stw-d9a6d631f7cfdab5a120a6b0104ce2dbf8644841
2008-06-16 11:00:21 +00:00
pinky a83dce15e0 New trunk
bzr revid: pinky-dedd7f8a42bd4557112a0513082691b8590ad6cc
2006-12-07 13:41:40 +00:00