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
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'), fieldtype='Link', options='Salary Component', insert_after='hra_section'),
dict(fieldname='hra_component', label='HRA Component', dict(fieldname='hra_component', label='HRA Component',
fieldtype='Link', options='Salary Component', insert_after='basic_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', dict(fieldname='arrear_component', label='Arrear Component',
fieldtype='Link', options='Salary Component', insert_after='hra_component'), fieldtype='Link', options='Salary Component', insert_after='hra_component'),
dict(fieldname='non_profit_section', label='Non Profit Settings', 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'), fieldtype='Data', insert_after='non_profit_section'),
dict(fieldname='with_effect_from', label='80G With Effect From', dict(fieldname='with_effect_from', label='80G With Effect From',
fieldtype='Date', insert_after='company_80g_number'), 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', dict(fieldname='pan_details', label='PAN Number',
fieldtype='Data', insert_after='with_effect_from') 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) { company_name: function(frm) {
if(frm.doc.__islocal) { if(frm.doc.__islocal) {
// add missing " " arg in split method // add missing " " arg in split method
@@ -127,6 +164,10 @@ frappe.ui.form.on("Company", {
}, __('Manage')); }, __('Manage'));
} }
} }
frm.add_custom_button(__('Change Abbreviation'), () => {
frm.trigger('change_abbreviation');
}, __('Manage'));
} }
erpnext.company.set_chart_of_accounts_options(frm.doc); 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) { erpnext.company.setup_queries = function(frm) {
$.each([ $.each([
["default_bank_account", {"account_type": "Bank"}], ["default_bank_account", {"account_type": "Bank"}],

View File

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