From 3ad045302b22e65f016e85b2231cd1f77e7e7841 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Tue, 5 Sep 2017 15:23:55 +0530 Subject: [PATCH] [minor] set abbreviation on company name trigger (#10671) * [minor] set abbreviation on company name trigger * [minor] codecy fixes --- erpnext/setup/doctype/company/company.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 8c814e3de8..c15d737a31 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -8,6 +8,16 @@ frappe.ui.form.on("Company", { erpnext.company.setup_queries(frm); }, + company_name: function(frm) { + if(frm.doc.__islocal) { + let parts = frm.doc.company_name.split(); + let abbr = $.map(parts, function (p) { + return p? p.substr(0, 1) : null; + }).join(""); + frm.set_value("abbr", abbr); + } + }, + refresh: function(frm) { if(frm.doc.abbr && !frm.doc.__islocal) { frm.set_df_property("abbr", "read_only", 1);