Skip to content

Commit

Permalink
Merge pull request OCA#23 from guewen/13.0-shopfloor-fix-cluster-pick…
Browse files Browse the repository at this point in the history
…ing-pick-less-qty

cluster picking: fix reservation inconsistency
  • Loading branch information
guewen authored Jun 2, 2020
2 parents d455acb + a2e57f1 commit 35255e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
7 changes: 6 additions & 1 deletion shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,12 @@ def scan_destination_pack(self, picking_batch_id, move_line_id, barcode, quantit
# contained less items than expected)
remaining = move_line.product_uom_qty - quantity
new_line = move_line.copy({"product_uom_qty": remaining, "qty_done": 0})
move_line.product_uom_qty = quantity
# if we didn't bypass reservation update, the quant reservation
# would be reduced as much as the deduced quantity, which is wrong
# as we only moved the quantity to a new move line
move_line.with_context(
bypass_reservation_update=True
).product_uom_qty = quantity

search = self.actions_for("search")
bin_package = search.package_from_scan(barcode)
Expand Down
29 changes: 20 additions & 9 deletions shopfloor/tests/test_cluster_picking_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,15 @@ def test_scan_destination_pack_quantity_more(self):
def test_scan_destination_pack_quantity_less(self):
"""Pick less units than expected"""
line = self.one_line_picking.move_line_ids
quant = self.env["stock.quant"].search(
[
("location_id", "=", line.location_id.id),
("product_id", "=", line.product_id.id),
]
)
quant.ensure_one()
self.assertRecordValues(quant, [{"quantity": 40.0, "reserved_quantity": 20.0}])

# when we pick less quantity than expected, the line is split
# and the user is proposed to pick the next line for the remaining
# quantity
Expand All @@ -479,16 +488,7 @@ def test_scan_destination_pack_quantity_less(self):
"quantity": line.product_uom_qty - 3,
},
)

self.assertRecordValues(
line,
[{"qty_done": 7, "result_package_id": self.bin1.id, "product_uom_qty": 7}],
)
new_line = self.one_line_picking.move_line_ids - line
self.assertRecordValues(
new_line,
[{"qty_done": 0, "result_package_id": False, "product_uom_qty": 3}],
)

self.assert_response(
response,
Expand All @@ -502,6 +502,17 @@ def test_scan_destination_pack_quantity_less(self):
},
)

self.assertRecordValues(
line,
[{"qty_done": 7, "result_package_id": self.bin1.id, "product_uom_qty": 7}],
)
self.assertRecordValues(
new_line,
[{"qty_done": 0, "result_package_id": False, "product_uom_qty": 3}],
)
# the reserved quantity on the quant must stay the same
self.assertRecordValues(quant, [{"quantity": 40.0, "reserved_quantity": 20.0}])

def test_scan_destination_pack_zero_check(self):
"""Location will be emptied, have to go to zero check"""
line = self.one_line_picking.move_line_ids
Expand Down

0 comments on commit 35255e4

Please sign in to comment.