Skip to content
Snippets Groups Projects
Commit bc719896 authored by Achraf (abz)'s avatar Achraf (abz)
Browse files

[FIX] stock: Don't set DO to ready if a move is empty


A stock move with 0 qty in initial demand is considered as 'ready'. But
those stock moves should be excluded of the picking state computation to
not false the readiness of the picking, especially if the delivery
policy is set to 'direct'.

opw-2611018

closes odoo/odoo#75564

X-original-commit: 92e266e6
Signed-off-by: default avatarWilliam Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: default avatarAchraf <abz-odoo@users.noreply.github.com>
parent 7d4d3d8f
No related branches found
No related tags found
No related merge requests found
......@@ -788,8 +788,10 @@ class StockMove(models.Model):
'confirmed': 1,
}
moves_todo = self\
.filtered(lambda move: move.state not in ['cancel', 'done'])\
.filtered(lambda move: move.state not in ['cancel', 'done'] and not (move.state == 'assigned' and not move.product_uom_qty))\
.sorted(key=lambda move: (sort_map.get(move.state, 0), move.product_uom_qty))
if not moves_todo:
return 'assigned'
# The picking should be the same for all moves.
if moves_todo[:1].picking_id and moves_todo[:1].picking_id.move_type == 'one':
most_important_move = moves_todo[0]
......
......@@ -797,3 +797,34 @@ class TestPacking(SavepointCase):
with Form(picking) as picking_form:
picking_form.package_level_ids.remove(0)
self.assertEqual(len(picking.move_lines), 1, 'Should have only 1 stock move')
def test_picking_state_with_null_qty(self):
receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=False))
picking_type_id = self.warehouse.out_type_id
receipt_form.picking_type_id = picking_type_id
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.product_uom_qty = 10
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productB
move_line.product_uom_qty = 10
receipt = receipt_form.save()
receipt.action_confirm()
self.assertEqual(receipt.state, 'confirmed')
receipt.move_ids_without_package[1].product_uom_qty = 0
self.assertEqual(receipt.state, 'confirmed')
receipt_form = Form(self.env['stock.picking'].with_context(default_immediate_transfer=True))
picking_type_id = self.warehouse.out_type_id
receipt_form.picking_type_id = picking_type_id
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productA
move_line.quantity_done = 10
with receipt_form.move_ids_without_package.new() as move_line:
move_line.product_id = self.productB
move_line.quantity_done = 10
receipt = receipt_form.save()
receipt.action_confirm()
self.assertEqual(receipt.state, 'assigned')
receipt.move_ids_without_package[1].product_uom_qty = 0
self.assertEqual(receipt.state, 'assigned')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment