Skip to content

Commit

Permalink
[FIX] shopfloor: cluster_picking do not create a new move line
Browse files Browse the repository at this point in the history
when a wrong product or a wrong lot is scanned
  • Loading branch information
mt-software-de authored and sebalix committed Jan 8, 2025
1 parent ce319df commit 5ac8b4a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
32 changes: 24 additions & 8 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,16 +695,32 @@ def _set_destination_pack_update_quantity(self, move_line, quantity, barcode):
if not product:
packaging = search.packaging_from_scan(barcode)
product = packaging.product_id
if product and move_line.product_id == product:
quantity += packaging.qty or 1.0
response = self._response_for_scan_destination(move_line, qty_done=quantity)
return response
if product:
if move_line.product_id == product:
quantity += packaging.qty or 1.0
response = self._response_for_scan_destination(
move_line, qty_done=quantity
)
return response
return self._response_for_scan_destination(
move_line,
message=self.msg_store.wrong_record(product),
qty_done=quantity,
)
# Handle barcode of a lot
lot = search.lot_from_scan(barcode)
if lot and move_line.lot_id == lot:
quantity += 1.0
response = self._response_for_scan_destination(move_line, qty_done=quantity)
return response
if lot:
if move_line.lot_id == lot:
quantity += 1.0
response = self._response_for_scan_destination(
move_line, qty_done=quantity
)
return response
return self._response_for_scan_destination(
move_line,
message=self.msg_store.wrong_record(lot),
qty_done=quantity,
)
return response

def scan_destination_pack(self, picking_batch_id, move_line_id, barcode, quantity):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2020 Camptocamp SA (http://www.camptocamp.com)
# Copyright 2024 Michael Tietz (MT Software) <mtietz@mt-software.de>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from .test_cluster_picking_base import ClusterPickingCommonCase
Expand Down Expand Up @@ -78,15 +79,16 @@ def test_scan_destination_pack_increment_with_wrong_product(self):
)
# Ensure the qty has not changed.
self.assertEqual(line.qty_done, previous_qty_done)

new_move_line = self.env["stock.move.line"].search(
[("move_id", "=", line.move_id.id), ("id", ">", line.id)]
)
self.assertFalse(new_move_line)
expected_qty_done = qty_done
self.assert_response(
response,
next_state="scan_destination",
data=self._line_data(line, qty_done=expected_qty_done),
message=self.service.msg_store.bin_not_found_for_barcode(
self.product_b.barcode
),
message=self.service.msg_store.wrong_record(self.product_b),
)

def test_scan_destination_pack_increment_with_packaging(self):
Expand Down

0 comments on commit 5ac8b4a

Please sign in to comment.