Skip to content

Commit

Permalink
feat: Reallow customizing company abbreviation on setup. (#36646)
Browse files Browse the repository at this point in the history
Co-authored-by: Bernd Oliver Sünderhauf <pancho@mailbox.org>
  • Loading branch information
dj12djdjs and Bernd Oliver Sünderhauf authored Aug 14, 2023
1 parent 716d5c0 commit ca34b63
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions erpnext/public/js/setup_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ erpnext.setup.slides_settings = [
fieldtype: 'Data',
reqd: 1
},
{ fieldtype: "Column Break" },
{
fieldname: 'company_abbr',
label: __('Company Abbreviation'),
fieldtype: 'Data',
hidden: 1
reqd: 1
},
{ fieldtype: "Section Break" },
{
fieldname: 'chart_of_accounts', label: __('Chart of Accounts'),
options: "", fieldtype: 'Select'
Expand Down Expand Up @@ -134,18 +136,20 @@ erpnext.setup.slides_settings = [
me.charts_modal(slide, chart_template);
});

slide.get_input("company_name").on("change", function () {
slide.get_input("company_name").on("input", function () {
let parts = slide.get_input("company_name").val().split(" ");
let abbr = $.map(parts, function (p) { return p ? p.substr(0, 1) : null }).join("");
slide.get_field("company_abbr").set_value(abbr.slice(0, 10).toUpperCase());
}).val(frappe.boot.sysdefaults.company_name || "").trigger("change");

slide.get_input("company_abbr").on("change", function () {
if (slide.get_input("company_abbr").val().length > 10) {
let abbr = slide.get_input("company_abbr").val();
if (abbr.length > 10) {
frappe.msgprint(__("Company Abbreviation cannot have more than 5 characters"));
slide.get_field("company_abbr").set_value("");
abbr = abbr.slice(0, 10);
}
});
slide.get_field("company_abbr").set_value(abbr);
}).val(frappe.boot.sysdefaults.company_abbr || "").trigger("change");
},

charts_modal: function(slide, chart_template) {
Expand Down

0 comments on commit ca34b63

Please sign in to comment.