Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: re-arrange company doctype fields #27091

Merged
merged 3 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions erpnext/regional/india/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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')
],
Expand Down
78 changes: 41 additions & 37 deletions erpnext/setup/doctype/company/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
nextchamp-saqib marked this conversation as resolved.
Show resolved Hide resolved
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) {
nextchamp-saqib marked this conversation as resolved.
Show resolved Hide resolved
frappe.msgprint(__("There were errors."));
return;
} else {
frm.set_value("abbr", args.new_abbr);
}
dialog.hide();
frm.refresh();
},
btn: this
})
nextchamp-saqib marked this conversation as resolved.
Show resolved Hide resolved
});
dialog.show();
},

company_name: function(frm) {
if(frm.doc.__islocal) {
// add missing " " arg in split method
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"}],
Expand Down
109 changes: 54 additions & 55 deletions erpnext/setup/doctype/company/company.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,48 @@
"details",
"company_name",
"abbr",
"change_abbr",
"default_currency",
"country",
"is_group",
"cb0",
"default_letter_head",
"tax_id",
"domain",
"date_of_establishment",
"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",
"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",
"chart_of_accounts",
"existing_company",
"tax_id",
"date_of_establishment",
"column_break_26",
"chart_of_accounts",
"charts_section",
"sales_settings",
"monthly_sales_target",
"default_buying_terms",
"sales_monthly_history",
"monthly_sales_target",
"total_monthly_sales",
"column_break_goals",
"default_selling_terms",
"default_warehouse_for_sales_return",
"credit_limit",
"transactions_annual_history",
"total_monthly_sales",
"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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -442,10 +435,6 @@
"no_copy": 1,
"options": "Account"
},
{
"fieldname": "section_break_22",
"fieldtype": "Section Break"
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "cost_center",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -741,14 +726,28 @@
"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",
"idx": 1,
"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",
Expand Down