Skip to content

Commit

Permalink
[IMP] shopfloor: location_content_transfer: Let Odoo manage the backo…
Browse files Browse the repository at this point in the history
…rder strategy

Prior to this change, when a line was partially picking the  created a new move for the remaining qty. We now let the validation mechanism of odoo create the remaining move since it will take into account the backorder strategy defined on the picking type
  • Loading branch information
lmignon committed Jan 17, 2024
1 parent 8cc7896 commit a5c06eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions shopfloor/services/location_content_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,10 @@ def set_destination_line(
self._lock_lines(move_line)

move_line.qty_done = quantity
remaining_move_line = move_line._split_partial_quantity()
# If a move line reference a move linked to others move lines (different
# locations), we have to split the move to process only the lines related to
# the current location.
move_line._extract_in_split_order({"user_id": self.env.uid})
remaining_move_line.qty_done = remaining_move_line.reserved_uom_qty

self._write_destination_on_lines(move_line, scanned_location)
stock = self._actions_for("stock")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ def test_set_destination_line_partial_qty(self):
move_line_c = original_picking.move_line_ids.filtered(
lambda m: m.product_id == self.product_c
)
move = move_line_c.move_id
self.assertEqual(move_line_c.reserved_uom_qty, 10)
self.assertEqual(move_line_c.qty_done, 10)
# Scan partial qty (6/10)
Expand All @@ -456,13 +455,16 @@ def test_set_destination_line_partial_qty(self):
self.assertEqual(move_line_c.state, "done")
self.assertEqual(original_picking.backorder_ids, done_picking)
self.assertEqual(done_picking.state, "done")
# the move is split with the remaining
self.assertEqual(original_picking.state, "assigned")

# the remaining move is put in a backorder
move = done_picking.backorder_ids.move_ids
self.assertEqual(move.picking_id.state, "assigned")

self.assertEqual(move.state, "assigned")
self.assertEqual(move.product_id, self.product_c)
self.assertEqual(move.product_uom_qty, 4)
self.assertEqual(move.move_line_ids.reserved_uom_qty, 4)
self.assertEqual(move.move_line_ids.qty_done, 4)
self.assertEqual(move.move_line_ids.qty_done, 0)
# Check the response
move_lines = self.service._find_transfer_move_lines(self.content_loc)
self.assert_response_start_single(
Expand Down Expand Up @@ -773,7 +775,6 @@ def test_set_destination_line_partial_qty_with_move_orig_ids(self):
move_line_c = picking_b.move_line_ids.filtered(
lambda m: m.product_id == self.product_c
)
move = move_line_c.move_id

self.assertEqual(move_line_c.reserved_uom_qty, 10)
self.assertEqual(move_line_c.qty_done, 10)
Expand All @@ -787,22 +788,21 @@ def test_set_destination_line_partial_qty_with_move_orig_ids(self):
"barcode": self.dest_location.barcode,
},
)
done_picking = move_line_c.picking_id
# Check move line data
self.assertEqual(picking_b.backorder_ids, done_picking)
self.assertEqual(move_line_c.move_id.product_uom_qty, 6)
self.assertEqual(move_line_c.reserved_uom_qty, 0)
self.assertEqual(move_line_c.qty_done, 6)
self.assertEqual(move_line_c.state, "done")
# the move has been split
move = move_line_c.picking_id.backorder_ids.move_ids
self.assertNotEqual(move_line_c.move_id, move)

# Check the move handling the remaining qty
self.assertEqual(move.state, "assigned")
move_line = move.move_line_ids
self.assertEqual(move_line.move_id.product_uom_qty, 4)
self.assertEqual(move_line.reserved_uom_qty, 4)
self.assertEqual(move_line.qty_done, 4)
self.assertEqual(move_line.qty_done, 0)

def test_set_destination_package_partial_qty_with_move_orig_ids(self):
"""Scanned destination location with partial qty, but related moves
Expand Down

0 comments on commit a5c06eb

Please sign in to comment.