diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 109f1bc9b64..5be68e60591 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -17,6 +17,7 @@ from pypika import Order import erpnext from erpnext.accounts.utils import build_qb_match_conditions from erpnext.stock.get_item_details import ItemDetailsCtx, _get_item_tax_template +from erpnext.stock.utils import get_combine_datetime # searches for active employees @@ -498,6 +499,13 @@ def get_batches_from_stock_ledger_entries(searchfields, txt, filters, start=0, p .limit(page_len) ) + if not filters.get("is_inward"): + if filters.get("posting_date") and filters.get("posting_time"): + query = query.where( + stock_ledger_entry.posting_datetime + <= get_combine_datetime(filters.posting_date, filters.posting_time) + ) + if not filters.get("include_expired_batches"): query = query.where((batch_table.expiry_date >= expiry_date) | (batch_table.expiry_date.isnull())) @@ -551,6 +559,13 @@ def get_batches_from_serial_and_batch_bundle(searchfields, txt, filters, start=0 .limit(page_len) ) + if not filters.get("is_inward"): + if filters.get("posting_date") and filters.get("posting_time"): + bundle_query = bundle_query.where( + stock_ledger_entry.posting_datetime + <= get_combine_datetime(filters.posting_date, filters.posting_time) + ) + if not filters.get("include_expired_batches"): bundle_query = bundle_query.where( (batch_table.expiry_date >= expiry_date) | (batch_table.expiry_date.isnull()) diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index 34326ad16dc..fd1e0c4167f 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -484,6 +484,8 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate { warehouse: this.item.s_warehouse || this.item.t_warehouse || this.item.warehouse, is_inward: is_inward, + posting_date: this.frm.doc.posting_date, + posting_time: this.frm.doc.posting_time, include_expired_batches: include_expired_batches, }, }; diff --git a/frappe-semgrep-rules b/frappe-semgrep-rules new file mode 160000 index 00000000000..a05bce32ad3 --- /dev/null +++ b/frappe-semgrep-rules @@ -0,0 +1 @@ +Subproject commit a05bce32ad3e37cf9a87a6913e9b08e45c8ba8cf