fix: duplicate serial nos

(cherry picked from commit c95465cba1)
This commit is contained in:
Rohit Waghchaure
2025-10-14 12:01:46 +05:30
committed by Mergify
parent 21a972ad95
commit 9854dedc06

View File

@@ -294,7 +294,7 @@ class SerialandBatchBundle(Document):
}
)
if self.returned_against and self.docstatus == 1:
if (self.returned_against or self.voucher_type == "Stock Reconciliation") and self.docstatus == 1:
kwargs["ignore_voucher_detail_no"] = self.voucher_detail_no
if self.docstatus == 1:
@@ -2677,7 +2677,10 @@ def get_stock_ledgers_for_serial_nos(kwargs):
else:
query = query.where(stock_ledger_entry[field] == kwargs.get(field))
if kwargs.voucher_no:
if kwargs.ignore_voucher_detail_no:
query = query.where(stock_ledger_entry.voucher_detail_no != kwargs.ignore_voucher_detail_no)
elif kwargs.voucher_no:
query = query.where(stock_ledger_entry.voucher_no != kwargs.voucher_no)
return query.run(as_dict=True)