diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 183ae053545..0514aa455bc 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1531,8 +1531,12 @@ def parse_naming_series_variable(doc, variable): else: data = {"YY": "%y", "YYYY": "%Y", "MM": "%m", "DD": "%d", "JJJ": "%j"} date = ( - getdate(doc.get("posting_date") or doc.get("transaction_date") or doc.get("posting_datetime")) - or now_datetime() + ( + getdate(doc.get("posting_date") or doc.get("transaction_date") or doc.get("posting_datetime")) + or now_datetime() + ) + if frappe.get_single_value("Global Defaults", "use_posting_datetime_for_naming_documents") + else now_datetime() ) return date.strftime(data[variable]) if variable in data else determine_consecutive_week_number(date) diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.json b/erpnext/setup/doctype/global_defaults/global_defaults.json index cb43c97ae4c..92bff6d4fbe 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.json +++ b/erpnext/setup/doctype/global_defaults/global_defaults.json @@ -13,6 +13,7 @@ "hide_currency_symbol", "disable_rounded_total", "disable_in_words", + "use_posting_datetime_for_naming_documents", "demo_company" ], "fields": [ @@ -80,6 +81,13 @@ "label": "Demo Company", "options": "Company", "read_only": 1 + }, + { + "default": "0", + "description": "When checked, the system will use the posting datetime of the document for naming the document instead of the creation datetime of the document.", + "fieldname": "use_posting_datetime_for_naming_documents", + "fieldtype": "Check", + "label": "Use Posting Datetime for Naming Documents" } ], "grid_page_length": 50, @@ -89,7 +97,7 @@ "in_create": 1, "issingle": 1, "links": [], - "modified": "2026-01-02 18:13:13.421866", + "modified": "2026-01-12 09:45:59.819161", "modified_by": "Administrator", "module": "Setup", "name": "Global Defaults", diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py index 4b7f642747e..99174c9a0d1 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.py +++ b/erpnext/setup/doctype/global_defaults/global_defaults.py @@ -39,6 +39,7 @@ class GlobalDefaults(Document): disable_in_words: DF.Check disable_rounded_total: DF.Check hide_currency_symbol: DF.Literal["", "No", "Yes"] + use_posting_datetime_for_naming_documents: DF.Check # end: auto-generated types def on_update(self):