From 6ebbbdbae98ece82deb48a14d54cf53f3988e4fa Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 7 Aug 2015 15:17:55 +0200 Subject: [PATCH] [FIX] stock: no uom rounding for DO availability & reservation Instead of rounding the availability and reversation of a delivery order line to the current UOM rounding, we round to the generic Product of measure precision. This is to have the real availability, even for a unit of measure that normally cannot be split. For instance, for a product for which the default uom is 'Unit(s)', but for a specific delivery order you deliver 1 'Dozens' of this product, if you have 6 Units available, it will now display that 0.500 'Dozens' is available and reserved, which is what is actually happening. Before, it displayed that 1 dozens was available, even if only 6 units were available, on the 12 needed. opw-643312 --- addons/stock/stock.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 114a724c1a0..524f0927a2b 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1684,12 +1684,14 @@ class stock_move(osv.osv): settings_obj = self.pool.get('stock.config.settings') uom_obj = self.pool.get('product.uom') res = dict.fromkeys(ids, '') + precision = self.pool['decimal.precision'].precision_get(cr, uid, 'Product Unit of Measure') for move in self.browse(cr, uid, ids, context=context): if move.state in ('draft', 'done', 'cancel') or move.location_id.usage != 'internal': res[move.id] = '' # 'not applicable' or 'n/a' could work too continue total_available = min(move.product_qty, move.reserved_availability + move.availability) - total_available = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, total_available, move.product_uom, context=context) + total_available = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, total_available, move.product_uom, round=False, context=context) + total_available = float_round(total_available, precision_digits=precision) info = str(total_available) #look in the settings if we need to display the UoM name or not config_ids = settings_obj.search(cr, uid, [], limit=1, order='id DESC', context=context) @@ -1700,7 +1702,8 @@ class stock_move(osv.osv): if move.reserved_availability: if move.reserved_availability != total_available: #some of the available quantity is assigned and some are available but not reserved - reserved_available = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, move.reserved_availability, move.product_uom, context=context) + reserved_available = uom_obj._compute_qty_obj(cr, uid, move.product_id.uom_id, move.reserved_availability, move.product_uom, round=False, context=context) + reserved_available = float_round(reserved_available, precision_digits=precision) info += _(' (%s reserved)') % str(reserved_available) else: #all available quantity is assigned