Skip to content

Commit

Permalink
Distinct full order picking
Browse files Browse the repository at this point in the history
  • Loading branch information
grindtildeath committed Sep 10, 2019
1 parent 55490bc commit 3da5e94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
16 changes: 14 additions & 2 deletions stock_picking_completion_info/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ class StockPicking(models.Model):
('no', 'No'),
(
'last_picking',
'Completion of this operation allows next operations to be '
'processed.',
'Last picking: Completion of this operation allows next '
'operations to be processed.',
),
(
'next_picking_ready',
'Next operations are ready to be processed.',
),
(
'full_order_picking',
'Full order picking: You are processing a full order picking '
'that will allow next operation to be processed'
)
],
compute='_compute_completion_info',
)
Expand All @@ -50,9 +55,16 @@ def _compute_completion_info(self):
depending_moves = picking.move_lines.mapped(
'move_dest_ids.picking_id.move_lines.move_orig_ids'
)
# If all the depending moves are done or canceled then next picking
# is ready to be processed
if all(m.state in ('done', 'cancel') for m in depending_moves):
picking.completion_info = 'next_picking_ready'
continue
# If all the depending moves are the moves on the actual picking
# then it's a full order and next picking is ready to be processed
if depending_moves == picking.move_lines:
picking.completion_info = 'full_order_picking'
continue
# If there aren't any depending move from another picking that is
# not done, then actual picking is the last to process
other_depending_moves = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def test_picking_all_at_once(self):
self.assertEqual(pick_move_1.state, 'confirmed')
self.assertEqual(pick_move_2.state, 'confirmed')
self.assertEqual(pick_order.state, 'confirmed')
self.assertEqual(pick_order.completion_info, 'last_picking')
self.assertEqual(pick_order.completion_info, 'full_order_picking')
pick_order.action_assign()
self.assertEqual(pick_move_1.state, 'assigned')
self.assertEqual(pick_move_2.state, 'assigned')
self.assertEqual(pick_order.state, 'assigned')
self.assertEqual(pick_order.completion_info, 'last_picking')
self.assertEqual(pick_order.completion_info, 'full_order_picking')
wiz = self.env['stock.immediate.transfer'].create(
{'pick_ids': [(4, pick_order.id)]}
)
Expand Down Expand Up @@ -223,12 +223,12 @@ def test_picking_with_backorder(self):
self.assertEqual(pick_move_1.state, 'confirmed')
self.assertEqual(pick_move_2.state, 'confirmed')
self.assertEqual(pick_order.state, 'confirmed')
self.assertEqual(pick_order.completion_info, 'last_picking')
self.assertEqual(pick_order.completion_info, 'full_order_picking')
pick_order.action_assign()
self.assertEqual(pick_move_1.state, 'assigned')
self.assertEqual(pick_move_2.state, 'assigned')
self.assertEqual(pick_order.state, 'assigned')
self.assertEqual(pick_order.completion_info, 'last_picking')
self.assertEqual(pick_order.completion_info, 'full_order_picking')
# Process partially to create backorder
pick_move_1.move_line_ids.qty_done = 1.0
pick_move_2.move_line_ids.qty_done = \
Expand Down
3 changes: 3 additions & 0 deletions stock_picking_completion_info/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<div class="alert alert-warning" attrs="{'invisible': [('completion_info', '!=', 'last_picking')]}" role="alert">
<field name="completion_info" nolabel="1" />
</div>
<div class="alert alert-primary" attrs="{'invisible': [('completion_info', '!=', 'full_order_picking')]}" role="alert">
<field name="completion_info" nolabel="1" />
</div>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 3da5e94

Please sign in to comment.