fix: not able to make purchase return for serial nos

This commit is contained in:
Rohit Waghchaure
2026-01-03 16:12:03 +05:30
parent 7bb0ec836f
commit 344572cf87
2 changed files with 10 additions and 0 deletions

View File

@@ -580,6 +580,14 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None, return_agai
):
target_doc.set("use_serial_batch_fields", 1)
if (
not source_doc.serial_no
and not source_doc.batch_no
and source_doc.serial_and_batch_bundle
and source_doc.use_serial_batch_fields
):
target_doc.set("use_serial_batch_fields", 0)
if source_doc.item_code and target_doc.get("use_serial_batch_fields"):
item_details = frappe.get_cached_value(
"Item", source_doc.item_code, ["has_batch_no", "has_serial_no"], as_dict=1

View File

@@ -4093,6 +4093,7 @@ class TestPurchaseReceipt(IntegrationTestCase):
sn_return.items[0].qty = -1
sn_return.items[0].received_qty = -1
sn_return.items[0].serial_no = pr1_serial_nos[0]
sn_return.items[0].use_serial_batch_fields = 1
sn_return.save()
self.assertRaises(frappe.ValidationError, sn_return.submit)
@@ -4127,6 +4128,7 @@ class TestPurchaseReceipt(IntegrationTestCase):
batch_return.items[0].qty = -1
batch_return.items[0].received_qty = -1
batch_return.items[0].batch_no = batch_no
batch_return.items[0].use_serial_batch_fields = 1
batch_return.save()
self.assertRaises(frappe.ValidationError, batch_return.submit)