diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index fc38aff9e2e..fbcc43231dd 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -3449,19 +3449,19 @@ def move_sample_to_retention_warehouse(company, items): sabe = next(item for item in sabb.entries if item.batch_no == batch_no) if sample_quantity: - total_qty += sample_quantity if sabb.has_serial_no: - sabe_list.extend( - [ - entry - for entry in sabb.entries - if entry.batch_no == batch_no - and frappe.db.exists( - "Serial No", {"name": entry.serial_no, "warehouse": warehouse} - ) - ][: int(sample_quantity)] - ) + new_sabe = [ + entry + for entry in sabb.entries + if entry.batch_no == batch_no + and frappe.db.exists( + "Serial No", {"name": entry.serial_no, "warehouse": warehouse} + ) + ][: int(sample_quantity)] + sabe_list.extend(new_sabe) + total_qty += len(new_sabe) else: + total_qty += sample_quantity sabe.qty = sample_quantity else: sabb.entries.remove(sabe) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 7b710514519..a0ac4f180b2 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -2291,7 +2291,7 @@ class TestStockEntry(IntegrationTestCase): "retain_sample": 1, "sample_quantity": 2, "has_batch_no": 1, - "has_seral_no": 1, + "has_serial_no": 1, "create_new_batch": 1, "batch_number_series": "SAMPLE-RET-.#####", "serial_no_series": "SAMPLE-RET-SN-.#####",