diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py index 5fe79384e6d5..647082baa687 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py @@ -186,6 +186,7 @@ def test_old_batch_valuation(self): } ) + doc.set_posting_datetime() doc.flags.ignore_permissions = True doc.flags.ignore_mandatory = True doc.flags.ignore_links = True @@ -586,6 +587,7 @@ def test_serial_no_valuation_for_legacy_ledgers(self): "company": "_Test Company", } ) + doc.set_posting_datetime() doc.flags.ignore_permissions = True doc.flags.ignore_mandatory = True doc.flags.ignore_links = True diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 5aeabeeec56c..6f5acd64d445 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -88,6 +88,7 @@ def validate(self): self.flags.ignore_submit_comment = True from erpnext.stock.utils import validate_disabled_warehouse, validate_warehouse_company + self.set_posting_datetime() self.validate_mandatory() self.validate_batch() validate_disabled_warehouse(self.warehouse) @@ -98,15 +99,10 @@ def validate(self): self.validate_with_last_transaction_posting_time() self.validate_inventory_dimension_negative_stock() - def set_posting_datetime(self, save=False): + def set_posting_datetime(self): from erpnext.stock.utils import get_combine_datetime - if save: - posting_datetime = get_combine_datetime(self.posting_date, self.posting_time) - if not self.posting_datetime or self.posting_datetime != posting_datetime: - self.db_set("posting_datetime", posting_datetime) - else: - self.posting_datetime = get_combine_datetime(self.posting_date, self.posting_time) + self.posting_datetime = get_combine_datetime(self.posting_date, self.posting_time) def validate_inventory_dimension_negative_stock(self): if self.is_cancelled or self.actual_qty >= 0: @@ -173,7 +169,6 @@ def _get_inventory_dimensions(self): return inv_dimension_dict def on_submit(self): - self.set_posting_datetime(save=True) self.check_stock_frozen_date() # Added to handle few test cases where serial_and_batch_bundles are not required diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 9754443d4ac9..a3673063a48e 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -1242,6 +1242,7 @@ def test_stock_reco_with_legacy_batch(self): } ) + doc.set_posting_datetime() doc.flags.ignore_permissions = True doc.flags.ignore_mandatory = True doc.flags.ignore_links = True diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 1e1b24115696..d11c19446bbf 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -222,7 +222,6 @@ def make_entry(args, allow_negative_stock=False, via_landed_cost_voucher=False): sle.flags.ignore_permissions = 1 sle.allow_negative_stock = allow_negative_stock sle.via_landed_cost_voucher = via_landed_cost_voucher - sle.set_posting_datetime() sle.submit() # Added to handle the case when the stock ledger entry is created from the repostig