mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
Merge pull request #51265 from frappe/mergify/bp/version-15-hotfix/pr-51251
fix: order by to fetch serial nos
This commit is contained in:
@@ -241,6 +241,7 @@ class SerialandBatchBundle(Document):
|
|||||||
"check_serial_nos": True,
|
"check_serial_nos": True,
|
||||||
"serial_nos": serial_nos,
|
"serial_nos": serial_nos,
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.voucher_type == "POS Invoice":
|
if self.voucher_type == "POS Invoice":
|
||||||
kwargs["ignore_voucher_nos"] = [self.voucher_no]
|
kwargs["ignore_voucher_nos"] = [self.voucher_no]
|
||||||
|
|
||||||
@@ -1976,9 +1977,9 @@ def get_available_serial_nos(kwargs):
|
|||||||
|
|
||||||
order_by = "creation"
|
order_by = "creation"
|
||||||
if kwargs.based_on == "LIFO":
|
if kwargs.based_on == "LIFO":
|
||||||
order_by = "creation desc"
|
order_by = "creation"
|
||||||
elif kwargs.based_on == "Expiry":
|
elif kwargs.based_on == "Expiry":
|
||||||
order_by = "amc_expiry_date asc"
|
order_by = "amc_expiry_date"
|
||||||
|
|
||||||
filters = {"item_code": kwargs.item_code}
|
filters = {"item_code": kwargs.item_code}
|
||||||
|
|
||||||
@@ -2025,7 +2026,12 @@ def get_serial_nos_based_on_filters(filters, fields, order_by, kwargs):
|
|||||||
doctype = frappe.qb.DocType("Serial No")
|
doctype = frappe.qb.DocType("Serial No")
|
||||||
|
|
||||||
order_by_column = getattr(doctype, order_by)
|
order_by_column = getattr(doctype, order_by)
|
||||||
query = frappe.qb.from_(doctype).orderby(order_by_column).limit(cint(kwargs.qty) or 10000000).for_update()
|
query = frappe.qb.from_(doctype).limit(cint(kwargs.qty) or 10000000).for_update()
|
||||||
|
|
||||||
|
if kwargs.based_on == "LIFO":
|
||||||
|
query = query.orderby(order_by_column, order=frappe.query_builder.Order.desc)
|
||||||
|
else:
|
||||||
|
query = query.orderby(order_by_column)
|
||||||
|
|
||||||
for key, value in filters.items():
|
for key, value in filters.items():
|
||||||
column = getattr(doctype, key)
|
column = getattr(doctype, key)
|
||||||
|
|||||||
Reference in New Issue
Block a user