mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
fix: ignore already fetched serial no
exclude_sr_nos is sent as JSON string of list, so load it before
operating on it.
(cherry picked from commit a18c687844)
This commit is contained in:
committed by
Ankush Menat
parent
315599b46f
commit
4e3bb12b3a
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import ValidationError, _
|
from frappe import ValidationError, _
|
||||||
@@ -591,14 +592,22 @@ def get_delivery_note_serial_no(item_code, qty, delivery_note):
|
|||||||
return serial_nos
|
return serial_nos
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def auto_fetch_serial_number(qty, item_code, warehouse,
|
def auto_fetch_serial_number(
|
||||||
posting_date=None, batch_nos=None, for_doctype=None, exclude_sr_nos=None):
|
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})
|
filters = frappe._dict({"item_code": item_code, "warehouse": warehouse})
|
||||||
|
|
||||||
if exclude_sr_nos is None:
|
if exclude_sr_nos is None:
|
||||||
exclude_sr_nos = []
|
exclude_sr_nos = []
|
||||||
else:
|
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)))
|
exclude_sr_nos = get_serial_nos(clean_serial_no_string("\n".join(exclude_sr_nos)))
|
||||||
|
|
||||||
if batch_nos:
|
if batch_nos:
|
||||||
|
|||||||
@@ -274,7 +274,8 @@ class TestSerialNo(FrappeTestCase):
|
|||||||
msg=f"{partial_fetch} should be subset of {first_fetch}")
|
msg=f"{partial_fetch} should be subset of {first_fetch}")
|
||||||
|
|
||||||
# exclusion
|
# 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)
|
self.assertEqual(sorted(remaining + partial_fetch), first_fetch)
|
||||||
|
|
||||||
# batchwise
|
# batchwise
|
||||||
|
|||||||
Reference in New Issue
Block a user