mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
perf: new column Posting Datetime in SLE to optimize stock ledger related queries (backport #39800) (#40004)
* perf: new column posting datetime in SLE to optimize stock ledger related queries (cherry picked from commitd80ca523a4) # Conflicts: # erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py * test: test cases to test clash timestamp entries (cherry picked from commitf04676aaed) * chore: remove microsecond from posting_datetime (cherry picked from commita73ba2c0d2) * chore: fix conflicts --------- Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from typing import Dict, Optional
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.query_builder.functions import CombineDatetime, IfNull, Sum
|
||||
from frappe.utils import cstr, flt, get_link_to_form, nowdate, nowtime
|
||||
from frappe.utils import cstr, flt, get_link_to_form, get_time, getdate, nowdate, nowtime
|
||||
|
||||
import erpnext
|
||||
from erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle import (
|
||||
@@ -657,3 +657,18 @@ def _update_item_info(scan_result: Dict[str, Optional[str]]) -> Dict[str, Option
|
||||
):
|
||||
scan_result.update(item_info)
|
||||
return scan_result
|
||||
|
||||
|
||||
def get_combine_datetime(posting_date, posting_time):
|
||||
import datetime
|
||||
|
||||
if isinstance(posting_date, str):
|
||||
posting_date = getdate(posting_date)
|
||||
|
||||
if isinstance(posting_time, str):
|
||||
posting_time = get_time(posting_time)
|
||||
|
||||
if isinstance(posting_time, datetime.timedelta):
|
||||
posting_time = (datetime.datetime.min + posting_time).time()
|
||||
|
||||
return datetime.datetime.combine(posting_date, posting_time).replace(microsecond=0)
|
||||
|
||||
Reference in New Issue
Block a user