Skip to content

Commit

Permalink
[IMP] shopfloor: Ensure destination location is also set on move
Browse files Browse the repository at this point in the history
  • Loading branch information
mt-software-de committed Jan 21, 2025
1 parent 89d6276 commit 9acedea
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
1 change: 1 addition & 0 deletions shopfloor/actions/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def _set_destination_on_lines(self, lines, location_dest):
lines_with_package_level.package_level_id.location_dest_id = location_dest
if lines_without_package_level:
lines_without_package_level.location_dest_id = location_dest
lines_without_package_level.move_id.location_dest_id = location_dest

def _unload_package(self, lines):
lines.result_package_id = False
Expand Down
74 changes: 71 additions & 3 deletions shopfloor/tests/test_single_pack_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def test_start_no_operation_create(self):
package_level = move_line.package_level_id

self.assertTrue(package_level.is_done)

self.assertEqual(move_line.location_id, self.pack_a.location_id)
self.assertEqual(move_line.move_id.location_id, self.pack_a.location_id)
expected_data = {
"id": package_level.id,
"name": package_level.package_id.name,
Expand All @@ -204,6 +205,60 @@ def test_start_no_operation_create(self):

self.assert_response(response, next_state="scan_location", data=expected_data)

def test_start_validate_no_operation_create(self):
self.menu.sudo().allow_move_create = True
self.picking.do_unreserve()
barcode = self.pack_a.name
params = {"barcode": barcode}

# Simulate the client scanning a package's barcode, which
# in turns should start the operation in odoo
response = self.service.dispatch("start", params=params)

move_line = self.env["stock.move.line"].search(
[("package_id", "=", self.pack_a.id)]
)
package_level = move_line.package_level_id

response = self.service.dispatch(
"validate",
params={
"package_level_id": package_level.id,
"location_barcode": self.shelf2.barcode,
},
)

self.assert_response(
response,
next_state="start",
message={
"message_type": "success",
"body": "The pack has been moved, you can scan a new pack.",
},
)

self.assertRecordValues(
package_level.move_line_ids,
[
{
"qty_done": 1.0,
"location_dest_id": self.shelf2.id,
"location_id": self.shelf1.id,
"state": "done",
}
],
)
self.assertRecordValues(
package_level.move_line_ids.move_id,
[
{
"location_dest_id": self.shelf2.id,
"location_id": self.shelf1.id,
"state": "done",
}
],
)

def test_start_barcode_not_known(self):
"""Test /start when the barcode is unknown
Expand Down Expand Up @@ -449,11 +504,24 @@ def test_validate(self):

self.assertRecordValues(
package_level.move_line_ids,
[{"qty_done": 1.0, "location_dest_id": self.shelf2.id, "state": "done"}],
[
{
"qty_done": 1.0,
"location_dest_id": self.shelf2.id,
"location_id": self.shelf1.id,
"state": "done",
}
],
)
self.assertRecordValues(
package_level.move_line_ids.move_id,
[{"location_dest_id": self.shelf2.id, "state": "done"}],
[
{
"location_dest_id": self.shelf2.id,
"location_id": self.shelf1.location_id.id,
"state": "done",
}
],
)

def test_validate_completion_info(self):
Expand Down
24 changes: 23 additions & 1 deletion shopfloor_single_product_transfer/tests/test_set_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestSetQuantity(CommonCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.location = cls.location_src
cls.location = cls.env.ref("stock.stock_location_components")
cls.product = cls.product_a
cls.packaging = cls.product_a_packaging
cls.packaging.qty = 5
Expand Down Expand Up @@ -429,6 +429,10 @@ def test_set_quantity_scan_packaging_with_allow_move_create(self):
self.assert_response(
response, next_state="select_product", message=expected_message, data=data
)
self.assertEqual(move_line.location_dest_id, self.dispatch_location)
self.assertEqual(move_line.location_id, location)
self.assertEqual(move_line.move_id.location_dest_id, self.dispatch_location)
self.assertEqual(move_line.move_id.location_id, location)

def test_set_quantity_scan_packaging_with_allow_move_create_and_no_prefill_qty(
self,
Expand Down Expand Up @@ -725,6 +729,15 @@ def test_set_quantity_scan_location(self):
self.assertFalse(picking.move_line_ids.result_package_id)
self.assertEqual(picking.user_id.id, False)
self.assertEqual(picking.move_line_ids.shopfloor_user_id.id, False)
self.assertEqual(picking.move_line_ids.location_dest_id, self.dispatch_location)
self.assertEqual(picking.move_line_ids.location_id, self.location)
self.assertEqual(
picking.move_line_ids.move_id.location_dest_id, self.dispatch_location
)
self.assertEqual(
picking.move_line_ids.move_id.location_id,
self.picking_type.default_location_src_id,
)

def test_set_quantity_scan_location_allow_move_create(self):
self.menu.sudo().allow_move_create = True
Expand Down Expand Up @@ -754,6 +767,15 @@ def test_set_quantity_scan_location_allow_move_create(self):
self.assertFalse(backorder)
self.assertEqual(picking.move_line_ids.qty_done, 6.0)
self.assertEqual(picking.move_line_ids.state, "done")
self.assertEqual(picking.move_line_ids.location_dest_id, self.dispatch_location)
self.assertEqual(picking.move_line_ids.location_id, self.location)
self.assertEqual(
picking.move_line_ids.move_id.location_dest_id, self.dispatch_location
)
self.assertEqual(
picking.move_line_ids.move_id.location_id,
self.picking_type.default_location_src_id,
)

def test_set_quantity_scan_package_not_empty(self):
# We scan a package that's not empty
Expand Down

0 comments on commit 9acedea

Please sign in to comment.