mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 16:15:02 +00:00
feat: support for serial item
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user