mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +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(
|
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"""
|
"""Get List of transactions for custom doctypes"""
|
||||||
from frappe.www.list import get_list
|
from frappe.www.list import get_list
|
||||||
@@ -59,7 +59,7 @@ def get_webform_transaction_list(
|
|||||||
limit_page_length,
|
limit_page_length,
|
||||||
ignore_permissions=False,
|
ignore_permissions=False,
|
||||||
fields=None,
|
fields=None,
|
||||||
order_by="modified",
|
order_by="creation",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ def get_transaction_list(
|
|||||||
filters=None,
|
filters=None,
|
||||||
limit_start=0,
|
limit_start=0,
|
||||||
limit_page_length=20,
|
limit_page_length=20,
|
||||||
order_by="modified",
|
order_by="creation",
|
||||||
custom=False,
|
custom=False,
|
||||||
):
|
):
|
||||||
user = frappe.session.user
|
user = frappe.session.user
|
||||||
@@ -117,7 +117,7 @@ def get_transaction_list(
|
|||||||
limit_page_length,
|
limit_page_length,
|
||||||
fields="name",
|
fields="name",
|
||||||
ignore_permissions=ignore_permissions,
|
ignore_permissions=ignore_permissions,
|
||||||
order_by="modified desc",
|
order_by="creation desc",
|
||||||
)
|
)
|
||||||
|
|
||||||
if custom:
|
if custom:
|
||||||
@@ -151,7 +151,7 @@ def get_list_for_transactions(
|
|||||||
limit_start=limit_start,
|
limit_start=limit_start,
|
||||||
limit_page_length=limit_page_length,
|
limit_page_length=limit_page_length,
|
||||||
ignore_permissions=ignore_permissions,
|
ignore_permissions=ignore_permissions,
|
||||||
order_by="modified desc",
|
order_by="creation desc",
|
||||||
):
|
):
|
||||||
data.append(d)
|
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):
|
def rfq_transaction_list(parties_doctype, doctype, parties, limit_start, limit_page_length):
|
||||||
data = frappe.db.sql(
|
data = frappe.db.sql(
|
||||||
"""select distinct parent as name, supplier from `tab{doctype}`
|
"""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
|
doctype=parties_doctype, supplier=parties[0], start=limit_start, len=limit_page_length
|
||||||
),
|
),
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ def get_last_interaction(contact=None, lead=None):
|
|||||||
FROM `tabCommunication`
|
FROM `tabCommunication`
|
||||||
WHERE `sent_or_received`='Received'
|
WHERE `sent_or_received`='Received'
|
||||||
AND ({})
|
AND ({})
|
||||||
ORDER BY `modified`
|
ORDER BY `creation`
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
""".format(
|
""".format(
|
||||||
query_condition
|
query_condition
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class BOMUpdateLog(Document):
|
|||||||
frappe.db.delete(
|
frappe.db.delete(
|
||||||
table,
|
table,
|
||||||
filters=(
|
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(
|
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)
|
customers, suppliers = get_customers_suppliers("Project", frappe.session.user)
|
||||||
|
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ def get_events(start, end, filters=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_timesheets_list(
|
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
|
user = frappe.session.user
|
||||||
# find customer name from contact.
|
# find customer name from contact.
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ class EmailDigest(Document):
|
|||||||
issue_list = frappe.db.sql(
|
issue_list = frappe.db.sql(
|
||||||
"""select *
|
"""select *
|
||||||
from `tabIssue` where status in ("Replied","Open")
|
from `tabIssue` where status in ("Replied","Open")
|
||||||
order by modified asc limit 10""",
|
order by creation asc limit 10""",
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ class EmailDigest(Document):
|
|||||||
project_list = frappe.db.sql(
|
project_list = frappe.db.sql(
|
||||||
"""select *
|
"""select *
|
||||||
from `tabProject` where status='Open' and project_type='External'
|
from `tabProject` where status='Open' and project_type='External'
|
||||||
order by modified asc limit 10""",
|
order by creation asc limit 10""",
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class RepostItemValuation(Document):
|
|||||||
frappe.db.delete(
|
frappe.db.delete(
|
||||||
table,
|
table,
|
||||||
filters=(
|
filters=(
|
||||||
(table.modified < (Now() - Interval(days=days)))
|
(table.creation < (Now() - Interval(days=days)))
|
||||||
& (table.status.isin(["Completed", "Skipped"]))
|
& (table.status.isin(["Completed", "Skipped"]))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class TestRepostItemValuation(FrappeTestCase, StockTestMixin):
|
|||||||
).insert(ignore_permissions=True)
|
).insert(ignore_permissions=True)
|
||||||
|
|
||||||
repost_doc.load_from_db()
|
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()
|
repost_doc.db_update_all()
|
||||||
|
|
||||||
logs = frappe.get_all("Repost Item Valuation", filters={"status": "Skipped"})
|
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")
|
webform_list_contexts = frappe.get_hooks("webform_list_context")
|
||||||
if webform_list_contexts:
|
if webform_list_contexts:
|
||||||
context = frappe._dict(frappe.get_attr(webform_list_contexts[0])("Buying") or {})
|
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)
|
return context.get_list(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class TestFormLoads(FrappeTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for doctype in doctypes:
|
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:
|
if not last_doc:
|
||||||
continue
|
continue
|
||||||
with self.subTest(msg=f"Loading {doctype} - {last_doc}", doctype=doctype, last_doc=last_doc):
|
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",
|
"Help Article",
|
||||||
fields="*",
|
fields="*",
|
||||||
filters={"category": category.name, "published": 1},
|
filters={"category": category.name, "published": 1},
|
||||||
order_by="modified desc",
|
order_by="creation desc",
|
||||||
limit=5,
|
limit=5,
|
||||||
)
|
)
|
||||||
if help_articles:
|
if help_articles:
|
||||||
|
|||||||
Reference in New Issue
Block a user