From e49beb0e1523e14af2b00e89745b4a0c332975c6 Mon Sep 17 00:00:00 2001 From: Somesh Khare Date: Tue, 24 Jul 2012 17:12:33 +0530 Subject: [PATCH 1/2] [FIX]stock_partial.picking: rounding issue with same or different uom in partial picking wizard (Case: Ref 577140) bzr revid: skh@tinyerp.com-20120724114233-rl1da0slx8t23mfu --- addons/stock/wizard/stock_partial_picking.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index 11eb41ac364..524aff4dbd8 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -22,6 +22,7 @@ import time from osv import fields, osv from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT +from tools.float_utils import float_compare import decimal_precision as dp from tools.translate import _ @@ -127,6 +128,7 @@ class stock_partial_picking(osv.osv_memory): stock_picking = self.pool.get('stock.picking') stock_move = self.pool.get('stock.move') uom_obj = self.pool.get('product.uom') + precision_obj = self.pool.get('decimal.precision') partial = self.browse(cr, uid, ids[0], context=context) partial_data = { 'delivery_date' : partial.date @@ -144,7 +146,7 @@ class stock_partial_picking(osv.osv_memory): qty_in_line_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, line_uom.id) if line_uom.factor and line_uom.factor <> 0: - if qty_in_line_uom <> wizard_line.quantity: + if float_compare(qty_in_line_uom, wizard_line.quantity, precision_digits=precision_obj.precision_get(cr, uid, 'Product UoM')) != 0: raise osv.except_osv(_('Warning'), _('The uom rounding does not allow you to ship "%s %s", only roundings of "%s %s" is accepted by the uom.') % (wizard_line.quantity, line_uom.name, line_uom.rounding, line_uom.name)) if move_id: #Check rounding Quantity.ex. @@ -155,7 +157,7 @@ class stock_partial_picking(osv.osv_memory): #Compute the quantity for respective wizard_line in the initial uom qty_in_initial_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, initial_uom.id) without_rounding_qty = (wizard_line.quantity / line_uom.factor) * initial_uom.factor - if qty_in_initial_uom <> without_rounding_qty: + if float_compare(qty_in_initial_uom, without_rounding_qty, precision_digits=precision_obj.precision_get(cr, uid, 'Product UoM')) != 0: raise osv.except_osv(_('Warning'), _('The rounding of the initial uom does not allow you to ship "%s %s", as it would let a quantity of "%s %s" to ship and only roundings of "%s %s" is accepted by the uom.') % (wizard_line.quantity, line_uom.name, wizard_line.move_id.product_qty - without_rounding_qty, initial_uom.name, initial_uom.rounding, initial_uom.name)) else: seq_obj_name = 'stock.picking.' + picking_type From d84e7e1c8c8e5a0566fd2a8ed89192299ee7cb40 Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Sun, 26 Aug 2012 22:59:54 +0200 Subject: [PATCH 2/2] [FIX] OPW 577140: stock: use float_compare() to check if initial and provided quantity equals - based on UoM rounding bzr revid: xal@openerp.com-20120826205954-of9eokcaiok3d7yt --- addons/stock/wizard/stock_partial_picking.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index 524aff4dbd8..8f1a46f79f0 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -128,7 +128,6 @@ class stock_partial_picking(osv.osv_memory): stock_picking = self.pool.get('stock.picking') stock_move = self.pool.get('stock.move') uom_obj = self.pool.get('product.uom') - precision_obj = self.pool.get('decimal.precision') partial = self.browse(cr, uid, ids[0], context=context) partial_data = { 'delivery_date' : partial.date @@ -146,7 +145,7 @@ class stock_partial_picking(osv.osv_memory): qty_in_line_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, line_uom.id) if line_uom.factor and line_uom.factor <> 0: - if float_compare(qty_in_line_uom, wizard_line.quantity, precision_digits=precision_obj.precision_get(cr, uid, 'Product UoM')) != 0: + if float_compare(qty_in_line_uom, wizard_line.quantity, precision_rounding=line_uom.rounding) != 0: raise osv.except_osv(_('Warning'), _('The uom rounding does not allow you to ship "%s %s", only roundings of "%s %s" is accepted by the uom.') % (wizard_line.quantity, line_uom.name, line_uom.rounding, line_uom.name)) if move_id: #Check rounding Quantity.ex. @@ -157,7 +156,7 @@ class stock_partial_picking(osv.osv_memory): #Compute the quantity for respective wizard_line in the initial uom qty_in_initial_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, initial_uom.id) without_rounding_qty = (wizard_line.quantity / line_uom.factor) * initial_uom.factor - if float_compare(qty_in_initial_uom, without_rounding_qty, precision_digits=precision_obj.precision_get(cr, uid, 'Product UoM')) != 0: + if float_compare(qty_in_initial_uom, without_rounding_qty, precision_rounding=initial_uom.rounding) != 0: raise osv.except_osv(_('Warning'), _('The rounding of the initial uom does not allow you to ship "%s %s", as it would let a quantity of "%s %s" to ship and only roundings of "%s %s" is accepted by the uom.') % (wizard_line.quantity, line_uom.name, wizard_line.move_id.product_qty - without_rounding_qty, initial_uom.name, initial_uom.rounding, initial_uom.name)) else: seq_obj_name = 'stock.picking.' + picking_type