mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 17:15:04 +00:00
@@ -3435,6 +3435,7 @@ def move_sample_to_retention_warehouse(company, items):
|
|||||||
)
|
)
|
||||||
sabb = cls_obj.duplicate_package()
|
sabb = cls_obj.duplicate_package()
|
||||||
batches = get_batch_nos(item.get("serial_and_batch_bundle"))
|
batches = get_batch_nos(item.get("serial_and_batch_bundle"))
|
||||||
|
sabe_list = []
|
||||||
for batch_no in batches.keys():
|
for batch_no in batches.keys():
|
||||||
sample_quantity = validate_sample_quantity(
|
sample_quantity = validate_sample_quantity(
|
||||||
item.get("item_code"),
|
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)
|
sabe = next(item for item in sabb.entries if item.batch_no == batch_no)
|
||||||
if sample_quantity:
|
if sample_quantity:
|
||||||
total_qty += 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:
|
else:
|
||||||
sabb.entries.remove(sabe)
|
sabb.entries.remove(sabe)
|
||||||
|
|
||||||
if total_qty:
|
if total_qty:
|
||||||
|
if sabe_list:
|
||||||
|
sabb.entries = sabe_list
|
||||||
sabb.save()
|
sabb.save()
|
||||||
stock_entry.append(
|
stock_entry.append(
|
||||||
"items",
|
"items",
|
||||||
|
|||||||
@@ -989,9 +989,10 @@ def get_batch_nos(serial_and_batch_bundle):
|
|||||||
|
|
||||||
entries = frappe.get_all(
|
entries = frappe.get_all(
|
||||||
"Serial and Batch Entry",
|
"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")},
|
filters={"parent": serial_and_batch_bundle, "batch_no": ("is", "set")},
|
||||||
order_by="idx",
|
order_by="idx",
|
||||||
|
group_by="batch_no",
|
||||||
)
|
)
|
||||||
|
|
||||||
if not entries:
|
if not entries:
|
||||||
|
|||||||
Reference in New Issue
Block a user