mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 07:58:38 +00:00
fix(stock): fix sqlparse token limit in get_bundle_wise_serial_nos
(cherry picked from commit 4544a6c935)
This commit is contained in:
@@ -2584,22 +2584,24 @@ def get_serial_nos_based_on_posting_date(kwargs, ignore_serial_nos):
|
|||||||
|
|
||||||
def get_bundle_wise_serial_nos(data, kwargs):
|
def get_bundle_wise_serial_nos(data, kwargs):
|
||||||
bundle_wise_serial_nos = defaultdict(list)
|
bundle_wise_serial_nos = defaultdict(list)
|
||||||
bundles = [d.serial_and_batch_bundle for d in data if d.serial_and_batch_bundle]
|
bundles = list({d.serial_and_batch_bundle for d in data if d.serial_and_batch_bundle})
|
||||||
if not bundles:
|
if not bundles:
|
||||||
return bundle_wise_serial_nos
|
return bundle_wise_serial_nos
|
||||||
|
|
||||||
filters = {"parent": ("in", bundles), "docstatus": 1, "serial_no": ("is", "set")}
|
sabe = frappe.qb.DocType("Serial and Batch Entry")
|
||||||
|
query = (
|
||||||
if kwargs.get("check_serial_nos") and kwargs.get("serial_nos"):
|
frappe.qb.from_(sabe)
|
||||||
filters["serial_no"] = ("in", kwargs.get("serial_nos"))
|
.select(sabe.serial_no, sabe.parent)
|
||||||
|
.where(sabe.parent.isin(bundles))
|
||||||
bundle_data = frappe.get_all(
|
.where(sabe.docstatus == 1)
|
||||||
"Serial and Batch Entry",
|
.where(sabe.serial_no.isnotnull())
|
||||||
fields=["serial_no", "parent"],
|
.where(sabe.serial_no != "")
|
||||||
filters=filters,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for d in bundle_data:
|
if kwargs.get("check_serial_nos") and kwargs.get("serial_nos"):
|
||||||
|
query = query.where(sabe.serial_no.isin(kwargs.get("serial_nos")))
|
||||||
|
|
||||||
|
for d in query.run(as_dict=True):
|
||||||
if d.parent:
|
if d.parent:
|
||||||
bundle_wise_serial_nos[d.parent].append(d.serial_no)
|
bundle_wise_serial_nos[d.parent].append(d.serial_no)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user