From 7a798dcba9e7c0721ad654334d71bd49999b7166 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 1 Jul 2026 09:10:18 +0530 Subject: [PATCH] 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 --- erpnext/stock/doctype/packed_item/packed_item.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index 5aff12994c9..9ec908c6b62 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -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: