fix(stock): tie-break pick-list lookup in update_packed_item_with_pick_list_info

The Pick List Item get_value orders only by qty desc; a pick list can hold multiple rows for the same
SO item split across warehouses/batches/serials that tie on qty, so MariaDB and Postgres could stamp a
different warehouse/batch/serial onto the packed item. Add a name tiebreaker.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-07-01 09:10:18 +05:30
parent 813dcca29a
commit 7a798dcba9

View File

@@ -326,7 +326,8 @@ def update_packed_item_with_pick_list_info(main_item_row, pi_row):
},
["warehouse", "batch_no", "serial_no"],
as_dict=True,
order_by="qty desc",
# name tiebreaker: split pick-list rows can tie on qty -> pick the same warehouse/batch/serial on both engines
order_by="qty desc, name asc",
)
if not pl_row: