feat: support for serial item

This commit is contained in:
Mihir Kandoi
2026-01-13 12:28:56 +05:30
parent b54067e04d
commit 3d0f649411
2 changed files with 13 additions and 2 deletions

View File

@@ -3435,6 +3435,7 @@ def move_sample_to_retention_warehouse(company, items):
)
sabb = cls_obj.duplicate_package()
batches = get_batch_nos(item.get("serial_and_batch_bundle"))
sabe_list = []
for batch_no in batches.keys():
sample_quantity = validate_sample_quantity(
item.get("item_code"),
@@ -3446,11 +3447,20 @@ 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
sabe.qty = -1 * sample_quantity
if sabb.has_serial_no:
sabe_list.extend(
[entry for entry in sabb.entries if entry.batch_no == batch_no][
: int(sample_quantity)
]
)
else:
sabe.qty = -1 * sample_quantity
else:
sabb.entries.remove(sabe)
if total_qty:
if sabe_list:
sabb.entries = sabe_list
sabb.save()
stock_entry.append(
"items",

View File

@@ -989,9 +989,10 @@ def get_batch_nos(serial_and_batch_bundle):
entries = frappe.get_all(
"Serial and Batch Entry",
fields=["batch_no", "qty", "name"],
fields=["batch_no", {"SUM": "qty", "as": "qty"}],
filters={"parent": serial_and_batch_bundle, "batch_no": ("is", "set")},
order_by="idx",
group_by="batch_no",
)
if not entries: