diff options
| author | Denis Ledoux <dle@openerp.com> | 2014-01-22 14:38:22 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@openerp.com> | 2014-01-22 14:38:22 +0100 |
| commit | d69ecb8d8f7e408976498cb83d784fb06de8094d (patch) | |
| tree | aecf0d81371469da81bdcbd920e0b9ca469cb1ca | |
| parent | 8e501b9c3bfefc7dbbff072cd1a56ed70708b991 (diff) | |
[FIX] mrp, stock: avoid float rounding errors using float_compare
bzr revid: dle@openerp.com-20140122133822-fkt5gqanpptlx9jx
| -rw-r--r-- | addons/mrp/mrp.py | 4 | ||||
| -rw-r--r-- | addons/stock/stock.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 075dbfe957d..038c608c26b 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -763,7 +763,7 @@ class mrp_production(osv.osv): # qty available for consume and produce qty_avail = scheduled.product_qty - consumed_data.get(scheduled.product_id.id, 0.0) - if qty_avail <= 0.0: + if float_compare(qty_avail, 0, precision_rounding=scheduled.product_id.uom_id.rounding) <= 0: # there will be nothing to consume for this raw material continue @@ -775,7 +775,7 @@ class mrp_production(osv.osv): # if qtys we have to consume is more than qtys available to consume prod_name = scheduled.product_id.name_get()[0][1] raise osv.except_osv(_('Warning!'), _('You are going to consume total %s quantities of "%s".\nBut you can only consume up to total %s quantities.') % (qty, prod_name, qty_avail)) - if qty <= 0.0: + if float_compare(qty, 0, precision_rounding=scheduled.product_id.uom_id.rounding) <= 0: # we already have more qtys consumed than we need continue diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 484bdc4cde2..02fd28611e6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2641,7 +2641,7 @@ class stock_move(osv.osv): quantity = move.product_qty uos_qty = quantity / move_qty * move.product_uos_qty - if quantity_rest > 0: + if float_compare(quantity_rest, 0, precision_rounding=move.product_id.uom_id.rounding): default_val = { 'product_qty': quantity, 'product_uos_qty': uos_qty, |
