refactor: usage of modified ordering (#40705)
Audited some important code:
- general_ledger.py
- stock_ledger.py
diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py
index 01b6f5c..0a0abda 100644
--- a/erpnext/controllers/website_list_for_contact.py
+++ b/erpnext/controllers/website_list_for_contact.py
@@ -35,7 +35,7 @@
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 @@
limit_page_length,
ignore_permissions=False,
fields=None,
- order_by="modified",
+ order_by="creation",
)
@@ -69,7 +69,7 @@
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 @@
limit_page_length,
fields="name",
ignore_permissions=ignore_permissions,
- order_by="modified desc",
+ order_by="creation desc",
)
if custom:
@@ -151,7 +151,7 @@
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 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,
diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py
index 6bcfcb7..3eca994 100644
--- a/erpnext/crm/doctype/utils.py
+++ b/erpnext/crm/doctype/utils.py
@@ -28,7 +28,7 @@
FROM `tabCommunication`
WHERE `sent_or_received`='Received'
AND ({})
- ORDER BY `modified`
+ ORDER BY `creation`
LIMIT 1
""".format(
query_condition
diff --git a/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py b/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py
index 198b9b8..9891e39 100644
--- a/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py
+++ b/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py
@@ -52,7 +52,7 @@
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")
),
)
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index 382437f..f5734ee 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -368,7 +368,7 @@
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)
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index d701496..dcd289e 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -479,7 +479,7 @@
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.
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index 4b07056..7ac7086 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -277,7 +277,7 @@
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 @@
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,
)
diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
index 4b7e0de..4ad3237 100644
--- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
+++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
@@ -63,7 +63,7 @@
frappe.db.delete(
table,
filters=(
- (table.modified < (Now() - Interval(days=days)))
+ (table.creation < (Now() - Interval(days=days)))
& (table.status.isin(["Completed", "Skipped"]))
),
)
diff --git a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py
index f96a612..950b436 100644
--- a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py
+++ b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py
@@ -99,7 +99,7 @@
).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"})
diff --git a/erpnext/tests/test_webform.py b/erpnext/tests/test_webform.py
index af50a05..8de0ca6 100644
--- a/erpnext/tests/test_webform.py
+++ b/erpnext/tests/test_webform.py
@@ -47,7 +47,7 @@
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)
diff --git a/erpnext/tests/test_zform_loads.py b/erpnext/tests/test_zform_loads.py
index 26e60c0..203a27e 100644
--- a/erpnext/tests/test_zform_loads.py
+++ b/erpnext/tests/test_zform_loads.py
@@ -17,7 +17,7 @@
)
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):
diff --git a/erpnext/www/support/index.py b/erpnext/www/support/index.py
index aa00e92..83fb895 100644
--- a/erpnext/www/support/index.py
+++ b/erpnext/www/support/index.py
@@ -76,7 +76,7 @@
"Help Article",
fields="*",
filters={"category": category.name, "published": 1},
- order_by="modified desc",
+ order_by="creation desc",
limit=5,
)
if help_articles: