feat: re-arrange company doctype fields (#27091)

This commit is contained in:
Saqib 2021-08-24 17:23:14 +05:30 committed by GitHub
parent d4d5a4221a
commit ce129a1414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 99 additions and 94 deletions

View File

@ -531,6 +531,7 @@ def make_custom_fields(update=True):
fieldtype='Link', options='Salary Component', insert_after='hra_section'),
dict(fieldname='hra_component', label='HRA Component',
fieldtype='Link', options='Salary Component', insert_after='basic_component'),
dict(fieldname='hra_column_break', fieldtype='Column Break', insert_after='hra_component'),
dict(fieldname='arrear_component', label='Arrear Component',
fieldtype='Link', options='Salary Component', insert_after='hra_component'),
dict(fieldname='non_profit_section', label='Non Profit Settings',
@ -539,6 +540,7 @@ def make_custom_fields(update=True):
fieldtype='Data', insert_after='non_profit_section'),
dict(fieldname='with_effect_from', label='80G With Effect From',
fieldtype='Date', insert_after='company_80g_number'),
dict(fieldname='non_profit_column_break', fieldtype='Column Break', insert_after='with_effect_from'),
dict(fieldname='pan_details', label='PAN Number',
fieldtype='Data', insert_after='with_effect_from')
],

View File

@ -46,6 +46,43 @@ frappe.ui.form.on("Company", {
});
},
change_abbreviation(frm) {
var dialog = new frappe.ui.Dialog({
title: "Replace Abbr",
fields: [
{"fieldtype": "Data", "label": "New Abbreviation", "fieldname": "new_abbr",
"reqd": 1 },
{"fieldtype": "Button", "label": "Update", "fieldname": "update"},
]
});
dialog.fields_dict.update.$input.click(function() {
var args = dialog.get_values();
if (!args) return;
frappe.show_alert(__("Update in progress. It might take a while."));
return frappe.call({
method: "erpnext.setup.doctype.company.company.enqueue_replace_abbr",
args: {
"company": frm.doc.name,
"old": frm.doc.abbr,
"new": args.new_abbr
},
callback: function(r) {
if (r.exc) {
frappe.msgprint(__("There were errors."));
return;
} else {
frm.set_value("abbr", args.new_abbr);
}
dialog.hide();
frm.refresh();
},
btn: this
});
});
dialog.show();
},
company_name: function(frm) {
if(frm.doc.__islocal) {
// add missing " " arg in split method
@ -127,6 +164,10 @@ frappe.ui.form.on("Company", {
}, __('Manage'));
}
}
frm.add_custom_button(__('Change Abbreviation'), () => {
frm.trigger('change_abbreviation');
}, __('Manage'));
}
erpnext.company.set_chart_of_accounts_options(frm.doc);
@ -204,43 +245,6 @@ erpnext.company.set_chart_of_accounts_options = function(doc) {
}
}
cur_frm.cscript.change_abbr = function() {
var dialog = new frappe.ui.Dialog({
title: "Replace Abbr",
fields: [
{"fieldtype": "Data", "label": "New Abbreviation", "fieldname": "new_abbr",
"reqd": 1 },
{"fieldtype": "Button", "label": "Update", "fieldname": "update"},
]
});
dialog.fields_dict.update.$input.click(function() {
var args = dialog.get_values();
if(!args) return;
frappe.show_alert(__("Update in progress. It might take a while."));
return frappe.call({
method: "erpnext.setup.doctype.company.company.enqueue_replace_abbr",
args: {
"company": cur_frm.doc.name,
"old": cur_frm.doc.abbr,
"new": args.new_abbr
},
callback: function(r) {
if(r.exc) {
frappe.msgprint(__("There were errors."));
return;
} else {
cur_frm.set_value("abbr", args.new_abbr);
}
dialog.hide();
cur_frm.refresh();
},
btn: this
})
});
dialog.show();
}
erpnext.company.setup_queries = function(frm) {
$.each([
["default_bank_account", {"account_type": "Bank"}],

View File

@ -12,33 +12,48 @@
"details",
"company_name",
"abbr",
"change_abbr",
"default_currency",
"country",
"is_group",
"cb0",
"domain",
"parent_company",
"charts_section",
"default_currency",
"default_letter_head",
"default_holiday_list",
"default_finance_book",
"default_selling_terms",
"default_buying_terms",
"default_warehouse_for_sales_return",
"default_in_transit_warehouse",
"column_break_10",
"country",
"create_chart_of_accounts_based_on",
"chart_of_accounts",
"existing_company",
"tax_id",
"domain",
"date_of_establishment",
"parent_company",
"company_info",
"company_logo",
"date_of_incorporation",
"phone_no",
"email",
"company_description",
"column_break1",
"date_of_commencement",
"fax",
"website",
"address_html",
"section_break_28",
"create_chart_of_accounts_based_on",
"existing_company",
"column_break_26",
"chart_of_accounts",
"charts_section",
"sales_settings",
"monthly_sales_target",
"default_buying_terms",
"sales_monthly_history",
"column_break_goals",
"transactions_annual_history",
"monthly_sales_target",
"total_monthly_sales",
"column_break_goals",
"default_selling_terms",
"default_warehouse_for_sales_return",
"credit_limit",
"transactions_annual_history",
"hr_settings_section",
"default_holiday_list",
"default_expense_claim_payable_account",
"column_break_10",
"default_employee_advance_account",
"default_payroll_payable_account",
"default_settings",
"default_bank_account",
"default_cash_account",
@ -52,24 +67,20 @@
"column_break0",
"allow_account_creation_against_child_company",
"default_payable_account",
"default_employee_advance_account",
"default_expense_account",
"default_income_account",
"default_deferred_revenue_account",
"default_deferred_expense_account",
"default_payroll_payable_account",
"default_expense_claim_payable_account",
"default_discount_account",
"section_break_22",
"cost_center",
"column_break_26",
"credit_limit",
"payment_terms",
"cost_center",
"default_finance_book",
"auto_accounting_for_stock_settings",
"enable_perpetual_inventory",
"enable_perpetual_inventory_for_non_stock_items",
"default_inventory_account",
"stock_adjustment_account",
"default_in_transit_warehouse",
"column_break_32",
"stock_received_but_not_billed",
"service_received_but_not_billed",
@ -79,25 +90,14 @@
"depreciation_expense_account",
"series_for_depreciation_entry",
"expenses_included_in_asset_valuation",
"repair_and_maintenance_account",
"column_break_40",
"disposal_account",
"depreciation_cost_center",
"capital_work_in_progress_account",
"repair_and_maintenance_account",
"asset_received_but_not_billed",
"budget_detail",
"exception_budget_approver_role",
"company_info",
"company_logo",
"date_of_incorporation",
"address_html",
"date_of_commencement",
"phone_no",
"fax",
"email",
"website",
"column_break1",
"company_description",
"registration_info",
"registration_details",
"lft",
@ -127,12 +127,6 @@
"oldfieldtype": "Data",
"reqd": 1
},
{
"depends_on": "eval:!doc.__islocal && in_list(frappe.user_roles, \"System Manager\")",
"fieldname": "change_abbr",
"fieldtype": "Button",
"label": "Change Abbreviation"
},
{
"bold": 1,
"default": "0",
@ -176,10 +170,9 @@
"label": "Company Description"
},
{
"collapsible": 1,
"fieldname": "sales_settings",
"fieldtype": "Section Break",
"label": "Sales Settings"
"label": "Buying & Selling Settings"
},
{
"fieldname": "sales_monthly_history",
@ -442,10 +435,6 @@
"no_copy": 1,
"options": "Account"
},
{
"fieldname": "section_break_22",
"fieldtype": "Section Break"
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "cost_center",
@ -455,10 +444,6 @@
"no_copy": 1,
"options": "Cost Center"
},
{
"fieldname": "column_break_26",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "credit_limit",
@ -589,10 +574,10 @@
},
{
"collapsible": 1,
"description": "For reference only.",
"depends_on": "eval: doc.docstatus == 0 && doc.__islocal != 1",
"fieldname": "company_info",
"fieldtype": "Section Break",
"label": "Company Info"
"label": "Address & Contact"
},
{
"fieldname": "date_of_incorporation",
@ -741,6 +726,20 @@
"fieldtype": "Link",
"label": "Repair and Maintenance Account",
"options": "Account"
},
{
"fieldname": "section_break_28",
"fieldtype": "Section Break",
"label": "Chart of Accounts"
},
{
"fieldname": "hr_settings_section",
"fieldtype": "Section Break",
"label": "HR & Payroll Settings"
},
{
"fieldname": "column_break_26",
"fieldtype": "Column Break"
}
],
"icon": "fa fa-building",
@ -748,7 +747,7 @@
"image_field": "company_logo",
"is_tree": 1,
"links": [],
"modified": "2021-05-12 16:51:08.187233",
"modified": "2021-07-12 11:27:06.353860",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",