java-topology/defects/erpnext-0002/patch/erpnext-0002-serial-batch-list-dedup.patch
russell@unturf.com 896a29f83b erp scan: erpnext-0001/0002, ofbiz-0001/0002; odoo CLEAN; 4/4 PASS
erpnext-0001: BOM.get_children list dedup O(B^2) MEDIUM 4x
erpnext-0002: serial_batch_bundle serial/batch dedup O(N^2) HIGH 45x
ofbiz-0001: PaymentGatewayServices processList LinkedList O(N^2) HIGH 45x
ofbiz-0002: OrderReturnServices/OrderReadHelper payment dedup O(N^2) MEDIUM 36x
odoo: CLEAN (consistent set/frozenset/OrderedSet usage throughout)
2026-03-30 15:24:39 -04:00

27 lines
1,004 B
Diff

# UNDF: UNDF-2026-000000863
--- a/erpnext/stock/serial_batch_bundle.py
+++ b/erpnext/stock/serial_batch_bundle.py
@@ -1556,13 +1556,17 @@
def get_serial_batch_list_from_item(item):
serial_list, batch_list = [], []
+ serial_set, batch_set = set(), set()
if item.serial_and_batch_bundle:
table = frappe.qb.DocType("Serial and Batch Entry")
query = (
frappe.qb.from_(table)
.select(table.serial_no, table.batch_no)
.where(table.parent == item.serial_and_batch_bundle)
)
result = query.run(as_dict=True)
for row in result:
- if row.serial_no and row.serial_no not in serial_list:
+ if row.serial_no and row.serial_no not in serial_set:
serial_list.append(row.serial_no)
- if row.batch_no and row.batch_no not in batch_list:
+ serial_set.add(row.serial_no)
+ if row.batch_no and row.batch_no not in batch_set:
batch_list.append(row.batch_no)
+ batch_set.add(row.batch_no)
else:
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos