diff --git a/cypress/fixtures/child_table_doctype.js b/cypress/fixtures/child_table_doctype.js index 88a925aca3..001eb638a8 100644 --- a/cypress/fixtures/child_table_doctype.js +++ b/cypress/fixtures/child_table_doctype.js @@ -24,7 +24,7 @@ export default { naming_rule: "By fieldname", owner: "Administrator", permissions: [], - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/child_table_doctype_1.js b/cypress/fixtures/child_table_doctype_1.js index abf8873bff..a13983df3c 100644 --- a/cypress/fixtures/child_table_doctype_1.js +++ b/cypress/fixtures/child_table_doctype_1.js @@ -53,7 +53,7 @@ export default { naming_rule: "By fieldname", owner: "Administrator", permissions: [], - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/custom_submittable_doctype.js b/cypress/fixtures/custom_submittable_doctype.js index 30aa698db4..6b100cd796 100644 --- a/cypress/fixtures/custom_submittable_doctype.js +++ b/cypress/fixtures/custom_submittable_doctype.js @@ -47,7 +47,7 @@ export default { }, ], quick_entry: 1, - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/data_field_validation_doctype.js b/cypress/fixtures/data_field_validation_doctype.js index 2901630d3f..01d17a4383 100644 --- a/cypress/fixtures/data_field_validation_doctype.js +++ b/cypress/fixtures/data_field_validation_doctype.js @@ -59,7 +59,7 @@ export default { }, ], quick_entry: 1, - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/datetime_doctype.js b/cypress/fixtures/datetime_doctype.js index f1a77ba6bb..4ecfd0f5ba 100644 --- a/cypress/fixtures/datetime_doctype.js +++ b/cypress/fixtures/datetime_doctype.js @@ -42,7 +42,7 @@ export default { }, ], quick_entry: 1, - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/doctype_to_link.js b/cypress/fixtures/doctype_to_link.js index ff5d1b5c68..8a2c5bb1a8 100644 --- a/cypress/fixtures/doctype_to_link.js +++ b/cypress/fixtures/doctype_to_link.js @@ -39,7 +39,7 @@ export default { write: 1, }, ], - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/doctype_with_child_table.js b/cypress/fixtures/doctype_with_child_table.js index 7caba516cf..f3c9f13848 100644 --- a/cypress/fixtures/doctype_with_child_table.js +++ b/cypress/fixtures/doctype_with_child_table.js @@ -46,7 +46,7 @@ export default { write: 1, }, ], - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/doctype_with_phone.js b/cypress/fixtures/doctype_with_phone.js index 06a24a5be5..a7d4e6803a 100644 --- a/cypress/fixtures/doctype_with_phone.js +++ b/cypress/fixtures/doctype_with_phone.js @@ -40,7 +40,7 @@ export default { cancel: 1, }, ], - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/doctype_with_tab_break.js b/cypress/fixtures/doctype_with_tab_break.js index 44d6c16682..61142b911d 100644 --- a/cypress/fixtures/doctype_with_tab_break.js +++ b/cypress/fixtures/doctype_with_tab_break.js @@ -48,7 +48,7 @@ export default { ], quick_entry: 1, autoname: "format: Test-{####}", - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/cypress/fixtures/form_builder_doctype.js b/cypress/fixtures/form_builder_doctype.js index 995971bed4..5b39970503 100644 --- a/cypress/fixtures/form_builder_doctype.js +++ b/cypress/fixtures/form_builder_doctype.js @@ -65,7 +65,7 @@ export default { write: 1, }, ], - sort_field: "modified", + sort_field: "creation", sort_order: "ASC", track_changes: 1, }; diff --git a/frappe/__init__.py b/frappe/__init__.py index 59d6e2fb72..4b7c77904b 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -2045,7 +2045,7 @@ def get_list(doctype, *args, **kwargs): :param doctype: DocType on which query is to be made. :param fields: List of fields or `*`. :param filters: List of filters (see example). - :param order_by: Order By e.g. `modified desc`. + :param order_by: Order By e.g. `creation desc`. :param limit_start: Start results at record #. Default 0. :param limit_page_length: No of records in the page. Default 20. @@ -2069,7 +2069,7 @@ def get_all(doctype, *args, **kwargs): :param doctype: DocType on which query is to be made. :param fields: List of fields or `*`. Default is: `["name"]`. :param filters: List of filters (see example). - :param order_by: Order By e.g. `modified desc`. + :param order_by: Order By e.g. `creation desc`. :param limit_start: Start results at record #. Default 0. :param limit_page_length: No of records in the page. Default 20. diff --git a/frappe/custom/fixtures/temp_doctype.json b/frappe/custom/fixtures/temp_doctype.json index 20b3d9caa9..08d9c230c5 100644 --- a/frappe/custom/fixtures/temp_doctype.json +++ b/frappe/custom/fixtures/temp_doctype.json @@ -24,7 +24,7 @@ "allow_import": 0, "allow_events_in_timeline": 0, "allow_auto_repeat": 0, - "sort_field": "modified", + "sort_field": "creation", "sort_order": "DESC", "document_type": "", "show_preview_popup": 0, diff --git a/frappe/custom/fixtures/temp_singles.json b/frappe/custom/fixtures/temp_singles.json index 723f47d7ac..a7a695117c 100644 --- a/frappe/custom/fixtures/temp_singles.json +++ b/frappe/custom/fixtures/temp_singles.json @@ -24,7 +24,7 @@ "allow_import": 0, "allow_events_in_timeline": 0, "allow_auto_repeat": 0, - "sort_field": "modified", + "sort_field": "creation", "sort_order": "DESC", "document_type": "", "show_preview_popup": 0, diff --git a/frappe/desk/form/utils.py b/frappe/desk/form/utils.py index b93ebdb5bc..2d8406790d 100644 --- a/frappe/desk/form/utils.py +++ b/frappe/desk/form/utils.py @@ -69,7 +69,7 @@ def update_comment(name, content): @frappe.whitelist() -def get_next(doctype, value, prev, filters=None, sort_order="desc", sort_field="modified"): +def get_next(doctype, value, prev, filters=None, sort_order="desc", sort_field="creation"): prev = int(prev) if not filters: filters = [] diff --git a/frappe/model/db_query.py b/frappe/model/db_query.py index 2f64b8f256..463af6a728 100644 --- a/frappe/model/db_query.py +++ b/frappe/model/db_query.py @@ -1073,16 +1073,16 @@ class DatabaseQuery: if self.doctype_meta.sort_field and "," in self.doctype_meta.sort_field: # multiple sort given in doctype definition # Example: - # `idx desc, modified desc` + # `idx desc, creation desc` # will covert to - # `tabItem`.`idx` desc, `tabItem`.`modified` desc + # `tabItem`.`idx` desc, `tabItem`.`creation` desc args.order_by = ", ".join( f"`tab{self.doctype}`.`{f_split[0].strip()}` {f_split[1].strip()}" for f in self.doctype_meta.sort_field.split(",") if (f_split := f.split(maxsplit=2)) ) else: - sort_field = self.doctype_meta.sort_field or "modified" + sort_field = self.doctype_meta.sort_field or "creation" sort_order = (self.doctype_meta.sort_field and self.doctype_meta.sort_order) or "desc" if self.order_by: args.order_by = ( @@ -1203,9 +1203,9 @@ def get_order_by(doctype, meta): if meta.sort_field and "," in meta.sort_field: # multiple sort given in doctype definition # Example: - # `idx desc, modified desc` + # `idx desc, creation desc` # will covert to - # `tabItem`.`idx` desc, `tabItem`.`modified` desc + # `tabItem`.`idx` desc, `tabItem`.`creation` desc order_by = ", ".join( f"`tab{doctype}`.`{f_split[0].strip()}` {f_split[1].strip()}" for f in meta.sort_field.split(",") @@ -1213,9 +1213,9 @@ def get_order_by(doctype, meta): ) else: - sort_field = meta.sort_field or "modified" + sort_field = meta.sort_field or "creation" sort_order = (meta.sort_field and meta.sort_order) or "desc" - order_by = f"`tab{doctype}`.`{sort_field or 'creation'}` {sort_order or 'desc'}" + order_by = f"`tab{doctype}`.`{sort_field}` {sort_order}" return order_by diff --git a/frappe/public/js/frappe/ui/sort_selector.js b/frappe/public/js/frappe/ui/sort_selector.js index cdad267eea..8c87f21656 100644 --- a/frappe/public/js/frappe/ui/sort_selector.js +++ b/frappe/public/js/frappe/ui/sort_selector.js @@ -64,7 +64,7 @@ frappe.ui.SortSelector = class SortSelector { this.args = {}; if (order_by.includes("`.`")) { - // scrub table name (separated by dot), like `tabTime Log`.`modified` desc` + // scrub table name (separated by dot), like `tabTime Log`.`creation` desc` order_by = order_by.split(".")[1]; }