Skip to content

Commit

Permalink
shopfloor: mark lines as sf_checkout_done when handled in backend
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr committed Feb 22, 2024
1 parent c114af4 commit 98b2baa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions shopfloor/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,16 @@ def split_assigned_move_lines(self, move_lines=None):
)
assigned_moves._action_assign()
return new_picking.id

def _put_in_pack(self, move_line_ids, create_package_level=True):
"""
Marks the corresponding move lines as 'shopfloor_checkout_done'
when the package is created in the backend.
"""
new_package = super()._put_in_pack(move_line_ids, create_package_level)
lines = self.move_line_ids.filtered(
lambda p: p.result_package_id == new_package
)
lines.write({"shopfloor_checkout_done": True})
return new_package
25 changes: 25 additions & 0 deletions shopfloor/tests/test_checkout_scan_package_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,28 @@ def test_scan_package_action_scan_not_found(self):
selected_line,
message={"message_type": "error", "body": "Barcode not found"},
)

def test_put_in_pack(self):
picking = self._create_picking(
lines=[(self.product_a, 10), (self.product_b, 20)]
)
self._fill_stock_for_moves(picking.move_lines)
picking.action_assign()

# Test that the move lines are marked as 'shopfloor_checkout_done'
# when putting them in a pack in the backend.
picking._put_in_pack(picking.move_line_ids)
self.assertTrue(
all(line.shopfloor_checkout_done for line in picking.move_line_ids)
)

# Check that we return those lines to the frontend.
res = self.service.dispatch(
"summary",
params={
"picking_id": picking.id,
},
)
returned_lines = res["data"]["summary"]["picking"]["move_lines"]
expected_line_ids = [line["id"] for line in returned_lines]
self.assertEqual(expected_line_ids, picking.move_line_ids.ids)

0 comments on commit 98b2baa

Please sign in to comment.