[FIX] stock: unreserve move only if reserved quants
An issue occurs in the following use case: - Enable "Bring goods to output location before shipping (Pick + Ship)" - Create a SO with 2 lines. 2 Deliveries are created, Pack and Ship. - Go to "Procurement Exceptions", and cancel one of the 2 lines - Go to the OUTgoing shipping, "Force Availability", and "Validate" An error occurs: "Cannot unreserve a done move". The system tries to unreserve a move which is actually cancelled. Actually, it should not be necessary to unreserve this move, since no quants were actually reserved in a first place. The fix ensures that, in this situation, we don't try to unreserve a move with no quant reserved. This should be safe to do it in all cases, but better be safe by adding the condition `if 'no_state_change' in context` to impact only this specific use case. opw-685650
This commit is contained in:
@@ -1554,12 +1554,18 @@ class stock_picking(models.Model):
|
||||
|
||||
def rereserve_quants(self, cr, uid, picking, move_ids=[], context=None):
|
||||
""" Unreserve quants then try to reassign quants."""
|
||||
if context is None:
|
||||
context = {}
|
||||
stock_move_obj = self.pool.get('stock.move')
|
||||
if not move_ids:
|
||||
self.do_unreserve(cr, uid, [picking.id], context=context)
|
||||
self.action_assign(cr, uid, [picking.id], context=context)
|
||||
else:
|
||||
stock_move_obj.do_unreserve(cr, uid, move_ids, context=context)
|
||||
if 'no_state_change' in context:
|
||||
move = stock_move_obj.browse(cr, uid, move_ids, context=context)
|
||||
stock_move_obj.do_unreserve(cr, uid, [m.id for m in move if m.reserved_quant_ids], context=context)
|
||||
else:
|
||||
stock_move_obj.do_unreserve(cr, uid, move_ids, context=context)
|
||||
stock_move_obj.action_assign(cr, uid, move_ids, no_prepare=True, context=context)
|
||||
|
||||
def do_new_transfer(self, cr, uid, ids, context=None):
|
||||
|
||||
Reference in New Issue
Block a user