chore: make feature opt in

(cherry picked from commit b8d4522ea1)
This commit is contained in:
Mihir Kandoi
2026-01-12 14:17:58 +05:30
committed by Mergify
parent b03494bb67
commit e9fa725030
3 changed files with 16 additions and 3 deletions

View File

@@ -1531,8 +1531,12 @@ def parse_naming_series_variable(doc, variable):
else: else:
data = {"YY": "%y", "YYYY": "%Y", "MM": "%m", "DD": "%d", "JJJ": "%j"} data = {"YY": "%y", "YYYY": "%Y", "MM": "%m", "DD": "%d", "JJJ": "%j"}
date = ( 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) return date.strftime(data[variable]) if variable in data else determine_consecutive_week_number(date)

View File

@@ -13,6 +13,7 @@
"hide_currency_symbol", "hide_currency_symbol",
"disable_rounded_total", "disable_rounded_total",
"disable_in_words", "disable_in_words",
"use_posting_datetime_for_naming_documents",
"demo_company" "demo_company"
], ],
"fields": [ "fields": [
@@ -80,6 +81,13 @@
"label": "Demo Company", "label": "Demo Company",
"options": "Company", "options": "Company",
"read_only": 1 "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, "grid_page_length": 50,
@@ -89,7 +97,7 @@
"in_create": 1, "in_create": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2026-01-02 18:13:13.421866", "modified": "2026-01-12 09:45:59.819161",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Global Defaults", "name": "Global Defaults",

View File

@@ -39,6 +39,7 @@ class GlobalDefaults(Document):
disable_in_words: DF.Check disable_in_words: DF.Check
disable_rounded_total: DF.Check disable_rounded_total: DF.Check
hide_currency_symbol: DF.Literal["", "No", "Yes"] hide_currency_symbol: DF.Literal["", "No", "Yes"]
use_posting_datetime_for_naming_documents: DF.Check
# end: auto-generated types # end: auto-generated types
def on_update(self): def on_update(self):