diff --git a/frappe/core/doctype/document_naming_settings/document_naming_settings.js b/frappe/core/doctype/document_naming_settings/document_naming_settings.js
index 39a4854288..15b0339f7a 100644
--- a/frappe/core/doctype/document_naming_settings/document_naming_settings.js
+++ b/frappe/core/doctype/document_naming_settings/document_naming_settings.js
@@ -2,25 +2,18 @@
// For license information, please see license.txt
frappe.ui.form.on("Document Naming Settings", {
- onload: function(frm) {
- frm.events.get_doc_and_prefix(frm);
- },
-
refresh: function(frm) {
+ frm.trigger("setup_transaction_autocomplete");
frm.disable_save();
},
- get_doc_and_prefix: function(frm) {
+ setup_transaction_autocomplete: function(frm) {
frappe.call({
method: "get_transactions",
doc: frm.doc,
callback: function(r) {
- frm.set_df_property(
- "transaction_type",
- "options",
- r.message.transactions
- );
- frm.set_df_property("prefix", "options", r.message.prefixes);
+ frm.fields_dict.transaction_type.set_data(r.message.transactions);
+ frm.fields_dict.prefix.set_data(r.message.prefixes);
},
});
},
@@ -53,7 +46,7 @@ frappe.ui.form.on("Document Naming Settings", {
method: "update_series",
doc: frm.doc,
callback: function(r) {
- frm.events.get_doc_and_prefix(frm);
+ frm.trigger("setup_transaction_autocomplete");
},
});
},
diff --git a/frappe/core/doctype/document_naming_settings/document_naming_settings.json b/frappe/core/doctype/document_naming_settings/document_naming_settings.json
index dccace9947..1dd84735b6 100644
--- a/frappe/core/doctype/document_naming_settings/document_naming_settings.json
+++ b/frappe/core/doctype/document_naming_settings/document_naming_settings.json
@@ -8,13 +8,12 @@
"naming_series_tab",
"setup_series",
"transaction_type",
- "try_naming_series",
- "preview",
- "add_series",
"naming_series_options",
"user_must_always_select",
"update",
"column_break_9",
+ "try_naming_series",
+ "preview",
"help_html",
"update_series",
"prefix",
@@ -34,7 +33,7 @@
"fieldname": "help_html",
"fieldtype": "HTML",
"label": "Help HTML",
- "options": "
\n Edit list of Series in the box below. Rules:\n
\n - Each Series Prefix on a new line.
\n - Allowed special characters are \"/\" and \"-\"
\n - \n Optionally, set the number of digits in the series using dot (.)\n followed by hashes (#). For example, \".####\" means that the series\n will have four digits. Default is five digits.\n
\n - \n You can also use variables in the series name by putting them\n between (.) dots\n
\n Support Variables:\n \n .YYYY. - Year in 4 digits \n .YY. - Year in 2 digits \n .MM. - Month \n .DD. - Day of month \n .WW. - Week of the year \n .FY. - Fiscal Year \n - \n
.{fieldname}. - fieldname on the document e.g.\n branch\n \n
\n \n
\n Examples:\n
\n - INV-
\n - INV-10-
\n - INVK-
\n - INV-.YYYY.-.{branch}.-.MM.-.####
\n
\n
\n
\n"
+ "options": "\n Edit list of Series in the box. Rules:\n
\n - Each Series Prefix on a new line.
\n - Allowed special characters are \"/\" and \"-\"
\n - \n Optionally, set the number of digits in the series using dot (.)\n followed by hashes (#). For example, \".####\" means that the series\n will have four digits. Default is five digits.\n
\n - \n You can also use variables in the series name by putting them\n between (.) dots\n
\n Supported Variables:\n \n .YYYY. - Year in 4 digits \n .YY. - Year in 2 digits \n .MM. - Month \n .DD. - Day of month \n .WW. - Week of the year \n .FY. - Fiscal Year \n - \n
.{fieldname}. - fieldname on the document e.g.\n branch\n \n
\n \n
\n Examples:\n
\n - INV-
\n - INV-10-
\n - INVK-
\n - INV-.YYYY.-.{branch}.-.MM.-.####
\n
\n
\n
\n"
},
{
"default": " ",
@@ -43,11 +42,6 @@
"label": "Preview of generated names",
"read_only": 1
},
- {
- "fieldname": "add_series",
- "fieldtype": "Button",
- "label": "Add this Series"
- },
{
"default": "0",
"depends_on": "transaction_type",
@@ -71,7 +65,7 @@
},
{
"fieldname": "prefix",
- "fieldtype": "Select",
+ "fieldtype": "Autocomplete",
"label": "Prefix"
},
{
@@ -93,13 +87,14 @@
"label": "Series List for this Transaction"
},
{
+ "depends_on": "transaction_type",
"fieldname": "try_naming_series",
"fieldtype": "Data",
"label": "Try a naming Series"
},
{
"fieldname": "transaction_type",
- "fieldtype": "Select",
+ "fieldtype": "Autocomplete",
"label": "Select Transaction"
},
{
diff --git a/frappe/core/doctype/document_naming_settings/document_naming_settings.py b/frappe/core/doctype/document_naming_settings/document_naming_settings.py
index b3f1ad0e97..1dd73062d3 100644
--- a/frappe/core/doctype/document_naming_settings/document_naming_settings.py
+++ b/frappe/core/doctype/document_naming_settings/document_naming_settings.py
@@ -58,9 +58,7 @@ class DocumentNamingSettings(Document):
if custom_prefixes:
prefixes = prefixes + [d.autoname.rsplit(".", 1)[0] for d in custom_prefixes]
- prefixes = "\n".join(sorted(prefixes))
-
- return {"transactions": "\n".join([""] + sorted(doctypes)), "prefixes": prefixes}
+ return {"transactions": sorted(doctypes), "prefixes": sorted(prefixes)}
def scrub_options_list(self, ol):
options = list(filter(lambda x: x, [cstr(n).strip() for n in ol]))