[IMP, REF] stock: Removed constrain of uom factor comparision and add warning on rounding uom quantity
bzr revid: ron@tinyerp.com-20111116123251-7b63br1570yapt0b
This commit is contained in:
parent
59a9f469da
commit
f3aa929bb0
|
@ -1167,7 +1167,7 @@ class stock_picking(osv.osv):
|
|||
wf_service = netsvc.LocalService("workflow")
|
||||
for pick in self.browse(cr, uid, ids, context=context):
|
||||
new_picking = None
|
||||
complete, too_few = [], []
|
||||
complete, too_many, too_few = [], [], []
|
||||
move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {}, {}, {}, {}, {}
|
||||
for move in pick.move_lines:
|
||||
if move.state in ('done', 'cancel'):
|
||||
|
@ -1184,8 +1184,11 @@ class stock_picking(osv.osv):
|
|||
partial_qty[move.id] = uom_obj._compute_qty(cr, uid, product_uoms[move.id], product_qty, move.product_uom.id)
|
||||
if move.product_qty == partial_qty[move.id]:
|
||||
complete.append(move)
|
||||
else:
|
||||
elif move.product_qty > partial_qty[move.id]:
|
||||
too_few.append(move)
|
||||
else:
|
||||
too_many.append(move)
|
||||
|
||||
# Average price computation
|
||||
if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
|
||||
product = product_obj.browse(cr, uid, move.product_id.id)
|
||||
|
@ -1247,6 +1250,7 @@ class stock_picking(osv.osv):
|
|||
{
|
||||
'product_qty' : move.product_qty - partial_qty[move.id],
|
||||
'product_uos_qty': move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
|
||||
|
||||
})
|
||||
|
||||
if new_picking:
|
||||
|
@ -1256,6 +1260,19 @@ class stock_picking(osv.osv):
|
|||
if prodlot_ids.get(move.id):
|
||||
defaults.update({'prodlot_id': prodlot_ids[move.id]})
|
||||
move_obj.write(cr, uid, [move.id], defaults)
|
||||
for move in too_many:
|
||||
product_qty = move_product_qty[move.id]
|
||||
defaults = {
|
||||
'product_qty' : product_qty,
|
||||
'product_uos_qty': product_qty, #TODO: put correct uos_qty
|
||||
'product_uom': product_uoms[move.id]
|
||||
}
|
||||
prodlot_id = prodlot_ids.get(move.id)
|
||||
if prodlot_ids.get(move.id):
|
||||
defaults.update(prodlot_id=prodlot_id)
|
||||
if new_picking:
|
||||
defaults.update(picking_id=new_picking)
|
||||
move_obj.write(cr, uid, [move.id], defaults)
|
||||
|
||||
# At first we confirm the new picking (if necessary)
|
||||
if new_picking:
|
||||
|
|
|
@ -129,16 +129,20 @@ class stock_partial_picking(osv.osv_memory):
|
|||
move_id = move.move_id.id
|
||||
|
||||
#Quantiny must be Positive
|
||||
if move.quantity <= 0:
|
||||
if move.quantity < 0:
|
||||
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
|
||||
#Pikcing move product UOM factor must be bigger with respective wizard move product uom factor
|
||||
if move_uom.factor < process_uom.factor:
|
||||
raise osv.except_osv(_('Warning'), _('You can not process in UOM "%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
|
||||
|
||||
#Compute the wizard Quantity for respective move.
|
||||
toprocess = uom_obj._compute_qty(cr, uid, process_uom.id, move.quantity, move_uom.id)
|
||||
#Compare wizard Quantity with respective picking move quantity if wizard move quantity bigger then it's giving warning.
|
||||
if toprocess > move.move_id.product_qty:
|
||||
raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (move.quantity, process_uom.name, move.move_id.product_qty, move_uom.name))
|
||||
|
||||
#Check rounding Quantity.ex.
|
||||
#picking: 1kg, uom kg rounding = 0.01 (rounding to 10g),
|
||||
#partial delivery: 253g
|
||||
#=> result= refused, as the qty left on picking would be 0.747kg and only 0.75 is accepted by the uom.
|
||||
if process_uom.factor and process_uom.factor <> 0 and move_uom.factor:
|
||||
without_rounding_qty = (move.quantity / process_uom.factor) * move_uom.factor
|
||||
if toprocess <> without_rounding_qty:
|
||||
raise osv.except_osv(_('Warning'), _('Quantity left on picking would be "%s %s" but "%s %s" is accepted by the uom.') % (without_rounding_qty, process_uom.name, toprocess, process_uom.name))
|
||||
|
||||
if not move_id:
|
||||
seq_obj_name = 'stock.picking.' + picking_type
|
||||
|
|
Loading…
Reference in New Issue