[FIX] mrp, stock: avoid float rounding errors using float_compare

bzr revid: dle@openerp.com-20140122133822-fkt5gqanpptlx9jx
This commit is contained in:
Denis Ledoux 2014-01-22 14:38:22 +01:00
parent 8e501b9c3b
commit d69ecb8d8f
2 changed files with 3 additions and 3 deletions

View File

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

View File

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