fix: ignore already fetched serial no
exclude_sr_nos is sent as JSON string of list, so load it before operating on it.
This commit is contained in:
parent
ec04242d72
commit
a18c687844
@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
import json
|
||||
from typing import List, Optional, Union
|
||||
|
||||
import frappe
|
||||
from frappe import ValidationError, _
|
||||
@ -574,14 +575,22 @@ def get_delivery_note_serial_no(item_code, qty, delivery_note):
|
||||
return serial_nos
|
||||
|
||||
@frappe.whitelist()
|
||||
def auto_fetch_serial_number(qty, item_code, warehouse,
|
||||
posting_date=None, batch_nos=None, for_doctype=None, exclude_sr_nos=None):
|
||||
def auto_fetch_serial_number(
|
||||
qty: float,
|
||||
item_code: str,
|
||||
warehouse: str,
|
||||
posting_date: Optional[str] = None,
|
||||
batch_nos: Optional[Union[str, List[str]]] = None,
|
||||
for_doctype: Optional[str] = None,
|
||||
exclude_sr_nos: Optional[List[str]] = None
|
||||
) -> List[str]:
|
||||
|
||||
filters = frappe._dict({"item_code": item_code, "warehouse": warehouse})
|
||||
|
||||
if exclude_sr_nos is None:
|
||||
exclude_sr_nos = []
|
||||
else:
|
||||
exclude_sr_nos = safe_json_loads(exclude_sr_nos)
|
||||
exclude_sr_nos = get_serial_nos(clean_serial_no_string("\n".join(exclude_sr_nos)))
|
||||
|
||||
if batch_nos:
|
||||
|
@ -274,7 +274,8 @@ class TestSerialNo(FrappeTestCase):
|
||||
msg=f"{partial_fetch} should be subset of {first_fetch}")
|
||||
|
||||
# exclusion
|
||||
remaining = auto_fetch_serial_number(3, item_code, warehouse, exclude_sr_nos=partial_fetch)
|
||||
remaining = auto_fetch_serial_number(3, item_code, warehouse,
|
||||
exclude_sr_nos=json.dumps(partial_fetch))
|
||||
self.assertEqual(sorted(remaining + partial_fetch), first_fetch)
|
||||
|
||||
# batchwise
|
||||
|
Loading…
Reference in New Issue
Block a user