diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py index ba1d3f7b49e..576d129ee2d 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, overload import frappe -from frappe.utils import cint, flt +from frappe.utils import cint, flt, today import erpnext from erpnext.stock.utils import get_combine_datetime @@ -77,6 +77,9 @@ def make_stock_entry(**args): if args.inspection_required: s.inspection_required = args.inspection_required + if not args.posting_date: + s.posting_date = today() + # map names if args.from_warehouse: args.source = args.from_warehouse @@ -142,8 +145,8 @@ def make_stock_entry(**args): batches = args.batches posting_datetime = None - if args.posting_date and args.posting_time: - posting_datetime = get_combine_datetime(args.posting_date, args.posting_time) + if s.posting_date and s.posting_time: + posting_datetime = get_combine_datetime(s.posting_date, s.posting_time) bundle_id = ( SerialBatchCreation( diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index e7f542a9774..a6f896ff385 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -25,7 +25,12 @@ from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import ( from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse from erpnext.stock.stock_ledger import get_previous_sle, update_entries_after from erpnext.stock.tests.test_utils import StockTestMixin -from erpnext.stock.utils import get_incoming_rate, get_stock_value_on, get_valuation_method +from erpnext.stock.utils import ( + get_combine_datetime, + get_incoming_rate, + get_stock_value_on, + get_valuation_method, +) class TestStockReconciliation(IntegrationTestCase, StockTestMixin): @@ -716,6 +721,13 @@ class TestStockReconciliation(IntegrationTestCase, StockTestMixin): rate=100, ) + stock_reco.reload() + stock_reco_sabb = stock_reco.items[0].serial_and_batch_bundle + posting_datetime = frappe.db.get_value("Serial and Batch Bundle", stock_reco_sabb, "posting_datetime") + self.assertEqual( + posting_datetime, get_combine_datetime(stock_reco.posting_date, stock_reco.posting_time) + ) + sle = frappe.get_all( "Stock Ledger Entry", filters={"is_cancelled": 0, "voucher_no": stock_reco.name, "actual_qty": ("<", 0)}, diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 6edaab5f698..bee190e13a1 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -241,12 +241,12 @@ def get_incoming_rate(args, raise_error_if_no_rate=True): """Get Incoming Rate based on valuation method""" from erpnext.stock.stock_ledger import get_previous_sle, get_valuation_rate - if not args.get("posting_datetime") and args.get("posting_date"): - args["posting_datetime"] = get_combine_datetime(args.get("posting_date"), args.get("posting_time")) - if isinstance(args, str): args = json.loads(args) + if not args.get("posting_datetime") and args.get("posting_date"): + args["posting_datetime"] = get_combine_datetime(args.get("posting_date"), args.get("posting_time")) + in_rate = None item_details = frappe.get_cached_value(