From e4e94b12da78bc8b077ea2df79a717f89e77093f Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 14 Apr 2011 14:36:20 +0530 Subject: [PATCH] [IMP]stock :Fixed:Add proper validation and refector code of do_partial picking bzr revid: ron@tinyerp.com-20110414090620-qx3o3cb5hum36yku --- addons/stock/stock.py | 3 ++- addons/stock/wizard/stock_partial_picking.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index d0287987afa..7e427e0eef6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1213,6 +1213,8 @@ class stock_picking(osv.osv): for move in too_few: + if move.product_qty < partial_qty[move.id]: + raise osv.except_osv(_('Error !'), _('You cannot select Quantity %s more then Picking Quantity %s.') % (partial_qty[move.id],move.product_qty,)) product_qty = move_product_qty[move.id] if not new_picking: new_picking = self.copy(cr, uid, pick.id, @@ -1235,7 +1237,6 @@ class stock_picking(osv.osv): if prodlot_id: defaults.update(prodlot_id=prodlot_id) move_obj.copy(cr, uid, move.id, defaults) - move_obj.write(cr, uid, [move.id], { 'product_qty' : move.product_qty - partial_qty[move.id], diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index e03af945604..61ae803d423 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -153,14 +153,15 @@ class stock_partial_picking(osv.osv_memory): for pick in pick_obj.browse(cr, uid, picking_ids, context=context): picking_type = self.get_picking_type(cr, uid, pick, context=context) moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out - picking_qty = 0.0 - partial_qty = 0.0 - for get_qty in pick.move_lines: - picking_qty += get_qty.product_qty for move in moves_list: - partial_qty += uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.product_id.uom_id.id) + picking_qty = 0.0 + partial_qty = 0.0 if move.product_uom.category_id.id <> move.product_id.uom_id.category_id.id: - raise osv.except_osv(_('Error !'), _('You are selected product uom category %s not same with picking product uom Category %s!.') % (move.product_uom.category_id.name,move.product_id.uom_id.category_id.name,)) + raise osv.except_osv(_('Error !'), _('You have selected product uom category %s not same with picking product uom Category %s!.') % (move.product_uom.category_id.name,move.product_id.uom_id.category_id.name,)) + for originalmove in pick.move_lines: + if originalmove.product_id.id == move.product_id.id: + picking_qty += uom_obj._compute_qty(cr, uid, originalmove.product_uom.id, originalmove.product_qty, originalmove.product_id.uom_id.id) + partial_qty += uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.product_id.uom_id.id) partial_datas['move%s' % (move.move_id.id)] = { 'product_id': move.id, 'product_qty': move.quantity, @@ -172,8 +173,8 @@ class stock_partial_picking(osv.osv_memory): 'product_price' : move.cost, 'product_currency': move.currency.id, }) - if picking_qty < partial_qty: - raise osv.except_osv(_('Error !'), _('You cannot select Quantity %s more then Picking Quantity %s.') % (partial_qty, picking_qty,)) + if picking_qty < partial_qty: + raise osv.except_osv(_('Error !'), _('You cannot select Quantity %s more then Picking Quantity %s.') % (partial_qty, picking_qty,)) pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context) return {'type': 'ir.actions.act_window_close'}