mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-15 23:54:59 +00:00
refactor: usage of modified ordering (#40705)
Audited some important code: - general_ledger.py - stock_ledger.py
This commit is contained in:
@@ -35,7 +35,7 @@ def get_webform_list_context(module):
|
||||
|
||||
|
||||
def get_webform_transaction_list(
|
||||
doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by="modified"
|
||||
doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by="creation"
|
||||
):
|
||||
"""Get List of transactions for custom doctypes"""
|
||||
from frappe.www.list import get_list
|
||||
@@ -59,7 +59,7 @@ def get_webform_transaction_list(
|
||||
limit_page_length,
|
||||
ignore_permissions=False,
|
||||
fields=None,
|
||||
order_by="modified",
|
||||
order_by="creation",
|
||||
)
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ def get_transaction_list(
|
||||
filters=None,
|
||||
limit_start=0,
|
||||
limit_page_length=20,
|
||||
order_by="modified",
|
||||
order_by="creation",
|
||||
custom=False,
|
||||
):
|
||||
user = frappe.session.user
|
||||
@@ -117,7 +117,7 @@ def get_transaction_list(
|
||||
limit_page_length,
|
||||
fields="name",
|
||||
ignore_permissions=ignore_permissions,
|
||||
order_by="modified desc",
|
||||
order_by="creation desc",
|
||||
)
|
||||
|
||||
if custom:
|
||||
@@ -151,7 +151,7 @@ def get_list_for_transactions(
|
||||
limit_start=limit_start,
|
||||
limit_page_length=limit_page_length,
|
||||
ignore_permissions=ignore_permissions,
|
||||
order_by="modified desc",
|
||||
order_by="creation desc",
|
||||
):
|
||||
data.append(d)
|
||||
|
||||
@@ -182,7 +182,7 @@ def get_list_for_transactions(
|
||||
def rfq_transaction_list(parties_doctype, doctype, parties, limit_start, limit_page_length):
|
||||
data = frappe.db.sql(
|
||||
"""select distinct parent as name, supplier from `tab{doctype}`
|
||||
where supplier = '{supplier}' and docstatus=1 order by modified desc limit {start}, {len}""".format(
|
||||
where supplier = '{supplier}' and docstatus=1 order by creation desc limit {start}, {len}""".format(
|
||||
doctype=parties_doctype, supplier=parties[0], start=limit_start, len=limit_page_length
|
||||
),
|
||||
as_dict=1,
|
||||
|
||||
@@ -28,7 +28,7 @@ def get_last_interaction(contact=None, lead=None):
|
||||
FROM `tabCommunication`
|
||||
WHERE `sent_or_received`='Received'
|
||||
AND ({})
|
||||
ORDER BY `modified`
|
||||
ORDER BY `creation`
|
||||
LIMIT 1
|
||||
""".format(
|
||||
query_condition
|
||||
|
||||
@@ -52,7 +52,7 @@ class BOMUpdateLog(Document):
|
||||
frappe.db.delete(
|
||||
table,
|
||||
filters=(
|
||||
(table.modified < (Now() - Interval(days=days))) & (table.update_type == "Update Cost")
|
||||
(table.creation < (Now() - Interval(days=days))) & (table.update_type == "Update Cost")
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ def get_timeline_data(doctype: str, name: str) -> dict[int, int]:
|
||||
|
||||
|
||||
def get_project_list(
|
||||
doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"
|
||||
doctype, txt, filters, limit_start, limit_page_length=20, order_by="creation"
|
||||
):
|
||||
customers, suppliers = get_customers_suppliers("Project", frappe.session.user)
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ def get_events(start, end, filters=None):
|
||||
|
||||
|
||||
def get_timesheets_list(
|
||||
doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"
|
||||
doctype, txt, filters, limit_start, limit_page_length=20, order_by="creation"
|
||||
):
|
||||
user = frappe.session.user
|
||||
# find customer name from contact.
|
||||
|
||||
@@ -277,7 +277,7 @@ class EmailDigest(Document):
|
||||
issue_list = frappe.db.sql(
|
||||
"""select *
|
||||
from `tabIssue` where status in ("Replied","Open")
|
||||
order by modified asc limit 10""",
|
||||
order by creation asc limit 10""",
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -301,7 +301,7 @@ class EmailDigest(Document):
|
||||
project_list = frappe.db.sql(
|
||||
"""select *
|
||||
from `tabProject` where status='Open' and project_type='External'
|
||||
order by modified asc limit 10""",
|
||||
order by creation asc limit 10""",
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class RepostItemValuation(Document):
|
||||
frappe.db.delete(
|
||||
table,
|
||||
filters=(
|
||||
(table.modified < (Now() - Interval(days=days)))
|
||||
(table.creation < (Now() - Interval(days=days)))
|
||||
& (table.status.isin(["Completed", "Skipped"]))
|
||||
),
|
||||
)
|
||||
|
||||
@@ -99,7 +99,7 @@ class TestRepostItemValuation(FrappeTestCase, StockTestMixin):
|
||||
).insert(ignore_permissions=True)
|
||||
|
||||
repost_doc.load_from_db()
|
||||
repost_doc.modified = add_days(now(), days=-i * 10)
|
||||
repost_doc.creation = add_days(now(), days=-i * 10)
|
||||
repost_doc.db_update_all()
|
||||
|
||||
logs = frappe.get_all("Repost Item Valuation", filters={"status": "Skipped"})
|
||||
|
||||
@@ -47,7 +47,7 @@ def get_data():
|
||||
webform_list_contexts = frappe.get_hooks("webform_list_context")
|
||||
if webform_list_contexts:
|
||||
context = frappe._dict(frappe.get_attr(webform_list_contexts[0])("Buying") or {})
|
||||
kwargs = dict(doctype="Order Assignment", order_by="modified desc")
|
||||
kwargs = dict(doctype="Order Assignment", order_by="creation desc")
|
||||
return context.get_list(**kwargs)
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class TestFormLoads(FrappeTestCase):
|
||||
)
|
||||
|
||||
for doctype in doctypes:
|
||||
last_doc = frappe.db.get_value(doctype, {}, "name", order_by="modified desc")
|
||||
last_doc = frappe.db.get_value(doctype, {}, "name", order_by="creation desc")
|
||||
if not last_doc:
|
||||
continue
|
||||
with self.subTest(msg=f"Loading {doctype} - {last_doc}", doctype=doctype, last_doc=last_doc):
|
||||
|
||||
@@ -76,7 +76,7 @@ def get_help_article_list():
|
||||
"Help Article",
|
||||
fields="*",
|
||||
filters={"category": category.name, "published": 1},
|
||||
order_by="modified desc",
|
||||
order_by="creation desc",
|
||||
limit=5,
|
||||
)
|
||||
if help_articles:
|
||||
|
||||
Reference in New Issue
Block a user