[minor] set abbreviation on company name trigger (#10671)

* [minor] set abbreviation on company name trigger

* [minor] codecy fixes
This commit is contained in:
Makarand Bauskar 2017-09-05 15:23:55 +05:30 committed by Nabin Hait
parent 499fbe90dc
commit 3ad045302b

View File

@ -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);