diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index f59ba1e103b5479f4e51aae1e6d1bd581760865b..89bfaf9e4c6e5b6c062ff5a8abeaead7f926ec05 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -1634,6 +1634,8 @@ def is_reposting_pending(): def future_sle_exists(args, sl_entries=None, allow_force_reposting=True): + from erpnext.stock.utils import get_combine_datetime + if allow_force_reposting and frappe.db.get_single_value( "Stock Reposting Settings", "do_reposting_for_each_stock_transaction" ): @@ -1655,14 +1657,15 @@ def future_sle_exists(args, sl_entries=None, allow_force_reposting=True): or_conditions = get_conditions_to_validate_future_sle(sl_entries) + args["posting_datetime"] = get_combine_datetime(args["posting_date"], args["posting_time"]) + data = frappe.db.sql( """ select item_code, warehouse, count(name) as total_row - from `tabStock Ledger Entry` force index (item_warehouse) + from `tabStock Ledger Entry` where ({}) - and timestamp(posting_date, posting_time) - >= timestamp(%(posting_date)s, %(posting_time)s) + and posting_datetime >= %(posting_datetime)s and voucher_no != %(voucher_no)s and is_cancelled = 0 GROUP BY