From 38c6b52770d33d91f67814cadf3031f6cdf32db3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 23 Apr 2015 13:14:17 +0530 Subject: [PATCH] [rename] group_or_ledger to is_group --- erpnext/accounts/doctype/account/account.js | 16 +-- erpnext/accounts/doctype/account/account.json | 20 ++-- erpnext/accounts/doctype/account/account.py | 16 +-- .../chart_of_accounts/chart_of_accounts.py | 28 ++--- .../ae_uae_chart_template_standard.json | 4 +- .../in_standard_chart_of_accounts.json | 14 +-- .../verified/ni_ni_chart_template.json | 62 +++++----- .../verified/standard_chart_of_accounts.py | 14 +-- .../accounts/doctype/account/test_account.py | 48 ++++---- .../bank_reconciliation.js | 2 +- .../doctype/cost_center/cost_center.js | 16 +-- .../doctype/cost_center/cost_center.json | 20 ++-- .../doctype/cost_center/cost_center.py | 11 +- .../doctype/cost_center/test_records.json | 6 +- erpnext/accounts/doctype/gl_entry/gl_entry.py | 4 +- .../doctype/journal_entry/journal_entry.js | 2 +- .../doctype/journal_entry/journal_entry.py | 2 +- .../mode_of_payment/mode_of_payment.js | 2 +- .../payment_reconciliation.js | 4 +- .../doctype/payment_tool/payment_tool.js | 2 +- .../period_closing_voucher.js | 4 +- .../doctype/pos_setting/pos_setting.js | 12 +- .../purchase_invoice/purchase_invoice.js | 4 +- .../purchase_invoice/purchase_invoice.py | 4 +- .../doctype/sales_invoice/sales_invoice.js | 12 +- .../doctype/sales_invoice/sales_invoice.py | 4 +- .../page/accounts_browser/accounts_browser.js | 27 ++--- .../page/accounts_browser/accounts_browser.py | 4 +- .../financial_analytics.js | 2 +- .../accounts_receivable.py | 11 -- .../bank_clearance_summary.js | 6 +- .../bank_reconciliation_statement.js | 2 +- .../report/general_ledger/general_ledger.py | 14 +-- erpnext/accounts/utils.py | 2 +- erpnext/buying/doctype/supplier/supplier.js | 2 +- erpnext/controllers/queries.py | 8 +- .../open_production_orders.json | 4 +- erpnext/patches.txt | 1 + erpnext/patches/v4_2/party_model.py | 4 +- erpnext/patches/v5_0/is_group.py | 9 ++ erpnext/public/js/account_tree_grid.js | 2 +- erpnext/public/js/controllers/accounts.js | 2 +- erpnext/selling/doctype/customer/customer.js | 2 +- erpnext/setup/doctype/company/company.js | 18 +-- erpnext/setup/doctype/company/company.py | 10 +- .../doctype/customer_group/customer_group.js | 2 +- .../doctype/email_digest/email_digest.py | 2 +- .../doctype/supplier_type/supplier_type.js | 2 +- .../setup/page/setup_wizard/setup_wizard.py | 107 ++++++++++-------- erpnext/startup/report_data_map.py | 2 +- .../doctype/delivery_note/delivery_note.js | 4 +- erpnext/stock/doctype/item/item.js | 8 +- .../stock/doctype/stock_entry/stock_entry.js | 2 +- .../stock_reconciliation.js | 4 +- erpnext/stock/doctype/warehouse/warehouse.js | 2 +- erpnext/stock/doctype/warehouse/warehouse.py | 2 +- 56 files changed, 295 insertions(+), 305 deletions(-) create mode 100644 erpnext/patches/v5_0/is_group.py diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 71acd62249..a2eb714f33 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -12,12 +12,12 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.toggle_display('account_name', doc.__islocal); // hide fields if group - cur_frm.toggle_display(['account_type', 'tax_rate'], doc.group_or_ledger=='Ledger') + cur_frm.toggle_display(['account_type', 'tax_rate'], cint(doc.is_group)==0) // disable fields - cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'company'], false); + cur_frm.toggle_enable(['account_name', 'is_group', 'company'], false); - if(doc.group_or_ledger=='Ledger') { + if(cint(doc.is_group)==0) { cur_frm.toggle_display('freeze_account', doc.__onload && doc.__onload.can_freeze_account); } @@ -40,7 +40,7 @@ cur_frm.add_fetch('parent_account', 'report_type', 'report_type'); cur_frm.add_fetch('parent_account', 'root_type', 'root_type'); cur_frm.cscript.account_type = function(doc, cdt, cdn) { - if(doc.group_or_ledger=='Ledger') { + if(doc.is_group==0) { cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax'); cur_frm.toggle_display('warehouse', doc.account_type=='Warehouse'); } @@ -50,10 +50,10 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) { cur_frm.add_custom_button(__('Chart of Accounts'), function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap') - if (cstr(doc.group_or_ledger) == 'Group') { - cur_frm.add_custom_button(__('Convert to Ledger'), + if (doc.is_group == 1) { + cur_frm.add_custom_button(__('Convert to non-Group'), function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet', 'btn-default'); - } else if (cstr(doc.group_or_ledger) == 'Ledger') { + } else if (cint(doc.is_group) == 0) { cur_frm.add_custom_button(__('View Ledger'), function() { frappe.route_options = { "account": doc.name, @@ -88,7 +88,7 @@ cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { cur_frm.fields_dict['parent_account'].get_query = function(doc) { return { filters: { - "group_or_ledger": "Group", + "is_group": 1, "company": doc.company } } diff --git a/erpnext/accounts/doctype/account/account.json b/erpnext/accounts/doctype/account/account.json index 4862962be6..fa3f81493f 100644 --- a/erpnext/accounts/doctype/account/account.json +++ b/erpnext/accounts/doctype/account/account.json @@ -38,18 +38,12 @@ "search_index": 1 }, { - "default": "Ledger", - "fieldname": "group_or_ledger", - "fieldtype": "Select", - "in_filter": 1, - "in_list_view": 1, - "label": "Group or Ledger", - "oldfieldname": "group_or_ledger", - "oldfieldtype": "Select", - "options": "\nLedger\nGroup", + "default": "0", + "fieldname": "is_group", + "fieldtype": "Check", + "label": "Is Group", "permlevel": 0, - "read_only": 1, - "reqd": 1, + "precision": "", "search_index": 1 }, { @@ -177,7 +171,7 @@ "icon": "icon-money", "idx": 1, "in_create": 0, - "modified": "2015-02-20 05:09:22.108350", + "modified": "2015-04-23 02:53:48.056520", "modified_by": "Administrator", "module": "Accounts", "name": "Account", @@ -261,5 +255,5 @@ "write": 1 } ], - "search_fields": "group_or_ledger" + "search_fields": "is_group" } \ No newline at end of file diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 23fa65602e..a824a129b7 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -32,12 +32,12 @@ class Account(Document): """Fetch Parent Details and validate parent account""" if self.parent_account: par = frappe.db.get_value("Account", self.parent_account, - ["name", "group_or_ledger", "report_type", "root_type", "company"], as_dict=1) + ["name", "is_group", "report_type", "root_type", "company"], as_dict=1) if not par: throw(_("Account {0}: Parent account {1} does not exist").format(self.name, self.parent_account)) elif par.name == self.name: throw(_("Account {0}: You can not assign itself as parent account").format(self.name)) - elif par.group_or_ledger != 'Group': + elif not par.is_group: throw(_("Account {0}: Parent account {1} can not be a ledger").format(self.name, self.parent_account)) elif par.company != self.company: throw(_("Account {0}: Parent account {1} does not belong to company: {2}") @@ -78,7 +78,7 @@ class Account(Document): elif self.check_gle_exists(): throw(_("Account with existing transaction cannot be converted to ledger")) else: - self.group_or_ledger = 'Ledger' + self.is_group = 0 self.save() return 1 @@ -88,7 +88,7 @@ class Account(Document): elif self.account_type: throw(_("Cannot covert to Group because Account Type is selected.")) else: - self.group_or_ledger = 'Group' + self.is_group = 1 self.save() return 1 @@ -160,10 +160,10 @@ class Account(Document): throw(_("Account {0} does not exist").format(new)) val = list(frappe.db.get_value("Account", new_account, - ["group_or_ledger", "root_type", "company"])) + ["is_group", "root_type", "company"])) - if val != [self.group_or_ledger, self.root_type, self.company]: - throw(_("""Merging is only possible if following properties are same in both records. Group or Ledger, Root Type, Company""")) + if val != [self.is_group, self.root_type, self.company]: + throw(_("""Merging is only possible if following properties are same in both records. Is Group, Root Type, Company""")) return new_account @@ -177,7 +177,7 @@ class Account(Document): def get_parent_account(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name from tabAccount - where group_or_ledger = 'Group' and docstatus != 2 and company = %s + where is_group = 1 and docstatus != 2 and company = %s and %s like %s order by name limit %s, %s""" % ("%s", searchfield, "%s", "%s", "%s"), (filters["company"], "%%%s%%" % txt, start, page_len), as_list=1) diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py index a27d739fae..7729d22377 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py @@ -13,18 +13,18 @@ def create_charts(chart_name, company): accounts = [] def _import_accounts(children, parent, root_type, root_account=False): - for account_name, children in children.items(): + for account_name, child in children.items(): if root_account: - root_type = children.get("root_type") + root_type = child.get("root_type") - if account_name not in ["account_type", "root_type", "group_or_ledger"]: + if account_name not in ["account_type", "root_type", "is_group"]: account_name_in_db = unidecode(account_name.strip().lower()) if account_name_in_db in accounts: count = accounts.count(account_name_in_db) account_name = account_name + " " + cstr(count) - group_or_ledger = identify_group_or_ledger(children) + is_group = identify_is_group(child) report_type = "Balance Sheet" if root_type in ["Asset", "Liability", "Equity"] \ else "Profit and Loss" @@ -33,10 +33,10 @@ def create_charts(chart_name, company): "account_name": account_name, "company": company, "parent_account": parent, - "group_or_ledger": group_or_ledger, + "is_group": is_group, "root_type": root_type, "report_type": report_type, - "account_type": children.get("account_type") + "account_type": child.get("account_type") }) if root_account: @@ -46,19 +46,19 @@ def create_charts(chart_name, company): accounts.append(account_name_in_db) - _import_accounts(children, account.name, root_type) + _import_accounts(child, account.name, root_type) _import_accounts(chart, None, None, root_account=True) -def identify_group_or_ledger(children): - if children.get("group_or_ledger"): - group_or_ledger = children.get("group_or_ledger") - elif len(set(children.keys()) - set(["account_type", "root_type", "group_or_ledger"])): - group_or_ledger = "Group" +def identify_is_group(child): + if child.get("is_group"): + is_group = child.get("is_group") + elif len(set(child.keys()) - set(["account_type", "root_type", "is_group"])): + is_group = 1 else: - group_or_ledger = "Ledger" + is_group = 0 - return group_or_ledger + return is_group def get_chart(chart_name): chart = {} diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/ae_uae_chart_template_standard.json b/erpnext/accounts/doctype/account/chart_of_accounts/verified/ae_uae_chart_template_standard.json index 58c45484a6..1ba0931b59 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/ae_uae_chart_template_standard.json +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/ae_uae_chart_template_standard.json @@ -85,7 +85,7 @@ }, "Stock in Hand": { "account_type": "Stock", - "group_or_ledger": "Group" + "is_group": 1 } }, "Perliminary and Preoperating Expenses": { @@ -326,7 +326,7 @@ }, "Duties and Taxes": { "account_type": "Tax", - "group_or_ledger": "Group" + "is_group": 1 }, "Accruals & Provisions": { "Accruals": { diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/in_standard_chart_of_accounts.json b/erpnext/accounts/doctype/account/chart_of_accounts/verified/in_standard_chart_of_accounts.json index 84e734ae8a..c2fbecc214 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/in_standard_chart_of_accounts.json +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/in_standard_chart_of_accounts.json @@ -12,7 +12,7 @@ }, "Bank Accounts": { "account_type": "Bank", - "group_or_ledger": "Group" + "is_group": 1 }, "Cash In Hand": { "Cash": { @@ -21,17 +21,17 @@ "account_type": "Cash" }, "Loans and Advances (Assets)": { - "group_or_ledger": "Group" + "is_group": 1 }, "Securities and Deposits": { "Earnest Money": {} }, "Stock Assets": { "account_type": "Stock", - "group_or_ledger": "Group" + "is_group": 1 }, "Tax Assets": { - "group_or_ledger": "Group" + "is_group": 1 } }, "Fixed Assets": { @@ -52,7 +52,7 @@ } }, "Investments": { - "group_or_ledger": "Group" + "is_group": 1 }, "Temporary Accounts (Assets)": { "Temporary Assets": {} @@ -146,7 +146,7 @@ }, "Indirect Income": { "account_type": "Income Account", - "group_or_ledger": "Group" + "is_group": 1 }, "root_type": "Income" }, @@ -168,7 +168,7 @@ }, "Duties and Taxes": { "account_type": "Tax", - "group_or_ledger": "Group" + "is_group": 1 }, "Loans (Liabilities)": { "Secured Loans": {}, diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/ni_ni_chart_template.json b/erpnext/accounts/doctype/account/chart_of_accounts/verified/ni_ni_chart_template.json index 6db540a503..eafc30982f 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/ni_ni_chart_template.json +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/ni_ni_chart_template.json @@ -32,7 +32,7 @@ } }, "Otros Equivalentes a Efectivo": { - "group_or_ledger": "Group", + "is_group": 1, "account_type": "Cash" } }, @@ -61,7 +61,7 @@ "Estimacion para Cuentas Incobrables": {} }, "Inventarios": { - "group_or_ledger": "Group", + "is_group": 1, "account_type": "Stock" }, "Impuestos Acreditables": { @@ -90,7 +90,7 @@ "Retenciones Definitivas Sobre Rentas o Ganancias de Capital": {} }, "Otras Cuentas por Cobrar": { - "group_or_ledger": "Group", + "is_group": 1, "account_type": "Receivable" } }, @@ -110,11 +110,11 @@ }, "Inversiones Permanentes": { "Inversiones Permanentes": { - "group_or_ledger": "Group", + "is_group": 1, "account_type": "Fixed Asset" }, "Negocios Conjuntos": { - "group_or_ledger": "Group", + "is_group": 1, "account_type": "Fixed Asset" } }, @@ -124,25 +124,25 @@ }, "Activos Intangibles": { "Patentes": { - "group_or_ledger": "Group" + "is_group": 1 }, "Marcas Registradas": { - "group_or_ledger": "Group" + "is_group": 1 }, "Derechos de Autor": { - "group_or_ledger": "Group" + "is_group": 1 }, "Concesiones": { - "group_or_ledger": "Group" + "is_group": 1 }, "Licencias": { - "group_or_ledger": "Group" + "is_group": 1 }, "Gastos de investigacion": { - "group_or_ledger": "Group" + "is_group": 1 }, "Amortizacion de Activos Intangibles": { - "group_or_ledger": "Group" + "is_group": 1 }, "Deterioro de Valor de Activos Intangibles": {} }, @@ -150,29 +150,29 @@ "Gastos de Consitucion": {}, "Gastos Pre Operativos": {}, "Mejoras en Bienes Arrendados": { - "group_or_ledger": "Group" + "is_group": 1 }, "Amortizacion de Activos Amortizables": {}, "Deterioro de Valaor de Activos Amortizables": {} }, "Cuentas por Cobrar a Largo Plazo": { "Creditos a Largo Plazo": { - "group_or_ledger": "Group" + "is_group": 1 } }, "Inversiones a Largo Plazo": { "Depositos Bancarios a Plazo": { - "group_or_ledger": "Group" + "is_group": 1 }, "Intereses percibidos por adelantado": { - "group_or_ledger": "Group" + "is_group": 1 }, "Titulos y Acciones": { - "group_or_ledger": "Group" + "is_group": 1 } }, "Activo por Impuestos Diferidos": { - "group_or_ledger": "Group" + "is_group": 1 } }, "root_type": "Asset" @@ -199,21 +199,21 @@ "Anticipos de Clientes": {}, "Pasivos Financieros a Corto Plazo": { "Prestamos por Pagar a Corto Plazo": { - "group_or_ledger": "Group" + "is_group": 1 }, "Sobregiros Bancarios": { - "group_or_ledger": "Group" + "is_group": 1 }, "Otras Deudas Bancarias": { - "group_or_ledger": "Group" + "is_group": 1 } }, "Gastos por Pagar": { "Servicios Basicos": { - "group_or_ledger": "Group" + "is_group": 1 }, "Prestaciones Sociales": { - "group_or_ledger": "Group" + "is_group": 1 }, "Salarios por Pagar": {} }, @@ -287,28 +287,28 @@ } }, "Otras Cuentas por Pagar": { - "group_or_ledger": "Group" + "is_group": 1 } }, "Pasivo No Corriente": { "Prestamos a Largo Plazo": { - "group_or_ledger": "Group" + "is_group": 1 }, "Cuentas por Pagar a Largo Plaso": { - "group_or_ledger": "Group" + "is_group": 1 }, "Otras Cuentas por Pagar a Largo Plazo": { - "group_or_ledger": "Group" + "is_group": 1 }, "Otros Pasivos Financieros a Largo Plaso": { - "group_or_ledger": "Group" + "is_group": 1 } }, "Obligaciones por Arrendamiento Financiero a Largo Plazo": { - "group_or_ledger": "Group" + "is_group": 1 }, "Pasivo por Impuestos Diferidos": { - "group_or_ledger": "Group" + "is_group": 1 }, "root_type": "Liability" }, @@ -324,7 +324,7 @@ } }, "Donaciones": { - "group_or_ledger": "Group" + "is_group": 1 }, "Ganancias Acumuladas": { "Reservas": { diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py index 72366315b7..50fc2f43dc 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/verified/standard_chart_of_accounts.py @@ -15,7 +15,7 @@ def get(): }, _("Bank Accounts"): { "account_type": "Bank", - "group_or_ledger": "Group" + "is_group": 1 }, _("Cash In Hand"): { _("Cash"): { @@ -24,17 +24,17 @@ def get(): "account_type": "Cash" }, _("Loans and Advances (Assets)"): { - "group_or_ledger": "Group" + "is_group": 1 }, _("Securities and Deposits"): { _("Earnest Money"): {} }, _("Stock Assets"): { "account_type": "Stock", - "group_or_ledger": "Group" + "is_group": 1 }, _("Tax Assets"): { - "group_or_ledger": "Group" + "is_group": 1 } }, _("Fixed Assets"): { @@ -55,7 +55,7 @@ def get(): } }, _("Investments"): { - "group_or_ledger": "Group" + "is_group": 1 }, _("Temporary Accounts (Assets)"): { _("Temporary Assets"): {} @@ -149,7 +149,7 @@ def get(): }, _("Indirect Income"): { "account_type": "Income Account", - "group_or_ledger": "Group" + "is_group": 1 }, "root_type": "Income" }, @@ -167,7 +167,7 @@ def get(): }, _("Duties and Taxes"): { "account_type": "Tax", - "group_or_ledger": "Group" + "is_group": 1 }, _("Loans (Liabilities)"): { _("Secured Loans"): {}, diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index 985b884ed3..2a3feda79b 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -8,37 +8,37 @@ def _make_test_records(verbose): from frappe.test_runner import make_test_objects accounts = [ - # [account_name, parent_account, group_or_ledger] - ["_Test Account Bank Account", "Bank Accounts", "Ledger", "Bank"], + # [account_name, parent_account, is_group] + ["_Test Account Bank Account", "Bank Accounts", 0, "Bank"], - ["_Test Account Stock Expenses", "Direct Expenses", "Group", None], - ["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"], - ["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger", "Tax"], - ["_Test Account Insurance Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"], - ["_Test Account Stock Adjustment", "_Test Account Stock Expenses", "Ledger", "Stock Adjustment"], + ["_Test Account Stock Expenses", "Direct Expenses", 1, None], + ["_Test Account Shipping Charges", "_Test Account Stock Expenses", 0, "Chargeable"], + ["_Test Account Customs Duty", "_Test Account Stock Expenses", 0, "Tax"], + ["_Test Account Insurance Charges", "_Test Account Stock Expenses", 0, "Chargeable"], + ["_Test Account Stock Adjustment", "_Test Account Stock Expenses", 0, "Stock Adjustment"], - ["_Test Account Tax Assets", "Current Assets", "Group", None], - ["_Test Account VAT", "_Test Account Tax Assets", "Ledger", "Tax"], - ["_Test Account Service Tax", "_Test Account Tax Assets", "Ledger", "Tax"], + ["_Test Account Tax Assets", "Current Assets", 1, None], + ["_Test Account VAT", "_Test Account Tax Assets", 0, "Tax"], + ["_Test Account Service Tax", "_Test Account Tax Assets", 0, "Tax"], - ["_Test Account Reserves and Surplus", "Current Liabilities", "Ledger", None], + ["_Test Account Reserves and Surplus", "Current Liabilities", 0, None], - ["_Test Account Cost for Goods Sold", "Expenses", "Ledger", None], - ["_Test Account Excise Duty", "_Test Account Tax Assets", "Ledger", "Tax"], - ["_Test Account Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"], - ["_Test Account S&H Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"], - ["_Test Account CST", "Direct Expenses", "Ledger", "Tax"], - ["_Test Account Discount", "Direct Expenses", "Ledger", None], - ["_Test Write Off", "Indirect Expenses", "Ledger", None], + ["_Test Account Cost for Goods Sold", "Expenses", 0, None], + ["_Test Account Excise Duty", "_Test Account Tax Assets", 0, "Tax"], + ["_Test Account Education Cess", "_Test Account Tax Assets", 0, "Tax"], + ["_Test Account S&H Education Cess", "_Test Account Tax Assets", 0, "Tax"], + ["_Test Account CST", "Direct Expenses", 0, "Tax"], + ["_Test Account Discount", "Direct Expenses", 0, None], + ["_Test Write Off", "Indirect Expenses", 0, None], # related to Account Inventory Integration - ["_Test Account Stock In Hand", "Current Assets", "Ledger", None], - ["_Test Account Fixed Assets", "Current Assets", "Ledger", None], + ["_Test Account Stock In Hand", "Current Assets", 0, None], + ["_Test Account Fixed Assets", "Current Assets", 0, None], # Receivable / Payable Account - ["_Test Receivable", "Current Assets", "Ledger", "Receivable"], - ["_Test Payable", "Current Liabilities", "Ledger", "Payable"], + ["_Test Receivable", "Current Assets", 0, "Receivable"], + ["_Test Payable", "Current Liabilities", 0, "Payable"], ] for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]: @@ -47,8 +47,8 @@ def _make_test_records(verbose): "account_name": account_name, "parent_account": parent_account + " - " + abbr, "company": company, - "group_or_ledger": group_or_ledger, + "is_group": is_group, "account_type": account_type - } for account_name, parent_account, group_or_ledger, account_type in accounts]) + } for account_name, parent_account, is_group, account_type in accounts]) return test_objects diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js index 96f9007d06..c39550b695 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js @@ -26,7 +26,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { return { "filters": { "account_type": "Bank", - "group_or_ledger": "Ledger" + "is_group": 0 } }; }); diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index 1b4451ff38..6946bcb106 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -18,7 +18,7 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({ filters:[ ['Account', 'company', '=', me.frm.doc.company], ['Account', 'report_type', '=', 'Profit and Loss'], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', '0'], ] } }); @@ -27,7 +27,7 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({ this.frm.set_query("parent_cost_center", function() { return { filters:[ - ['Cost Center', 'group_or_ledger', '=', 'Group'], + ['Cost Center', 'is_group', '=', '1'], ['Cost Center', 'company', '=', me.frm.doc.company], ] } @@ -40,15 +40,15 @@ $.extend(cur_frm.cscript, new erpnext.accounts.CostCenterController({frm: cur_fr cur_frm.cscript.refresh = function(doc, cdt, cdn) { var intro_txt = ''; cur_frm.toggle_display('cost_center_name', doc.__islocal); - cur_frm.toggle_enable(['group_or_ledger', 'company'], doc.__islocal); + cur_frm.toggle_enable(['is_group', 'company'], doc.__islocal); - if(!doc.__islocal && doc.group_or_ledger=='Group') { + if(!doc.__islocal && doc.is_group==1) { intro_txt += __('Note: This Cost Center is a Group. Cannot make accounting entries against groups.'); } cur_frm.cscript.hide_unhide_group_ledger(doc); - cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger') + cur_frm.toggle_display('sb1', doc.is_group==0) cur_frm.set_intro(intro_txt); cur_frm.add_custom_button(__('Chart of Cost Centers'), @@ -62,11 +62,11 @@ cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) { } cur_frm.cscript.hide_unhide_group_ledger = function(doc) { - if (cstr(doc.group_or_ledger) == 'Group') { - cur_frm.add_custom_button(__('Convert to Ledger'), + if (doc.is_group == 1) { + cur_frm.add_custom_button(__('Convert to non-Group'), function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet', "btn-default") - } else if (cstr(doc.group_or_ledger) == 'Ledger') { + } else if (doc.is_group == 0) { cur_frm.add_custom_button(__('Convert to Group'), function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet', "btn-default") diff --git a/erpnext/accounts/doctype/cost_center/cost_center.json b/erpnext/accounts/doctype/cost_center/cost_center.json index b37fa963f8..409f59ca90 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.json +++ b/erpnext/accounts/doctype/cost_center/cost_center.json @@ -58,18 +58,12 @@ "width": "50%" }, { - "fieldname": "group_or_ledger", - "fieldtype": "Select", - "hidden": 0, - "label": "Group or Ledger", - "no_copy": 1, - "oldfieldname": "group_or_ledger", - "oldfieldtype": "Select", - "options": "\nGroup\nLedger", + "default": "0", + "fieldname": "is_group", + "fieldtype": "Check", + "label": "Is Group", "permlevel": 0, - "print_hide": 1, - "report_hide": 1, - "reqd": 1 + "precision": "" }, { "description": "Define Budget for this Cost Center. To set budget action, see Company Master", @@ -145,7 +139,7 @@ "icon": "icon-money", "idx": 1, "in_create": 0, - "modified": "2015-02-20 05:07:59.251051", + "modified": "2015-04-23 02:54:26.934607", "modified_by": "Administrator", "module": "Accounts", "name": "Cost Center", @@ -198,5 +192,5 @@ "role": "Material User" } ], - "search_fields": "parent_cost_center" + "search_fields": "parent_cost_center, is_group" } \ No newline at end of file diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index b6cc50381e..f26c80ba59 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -16,9 +16,6 @@ class CostCenter(NestedSet): frappe.db.get_value("Company", self.company, "abbr") def validate_mandatory(self): - if not self.group_or_ledger: - msgprint(_("Please select Group or Ledger value"), raise_exception=1) - if self.cost_center_name != self.company and not self.parent_cost_center: msgprint(_("Please enter parent cost center"), raise_exception=1) elif self.cost_center_name == self.company and self.parent_cost_center: @@ -30,7 +27,7 @@ class CostCenter(NestedSet): elif self.check_gle_exists(): msgprint(_("Cost Center with existing transactions can not be converted to ledger"), raise_exception=1) else: - self.group_or_ledger = 'Ledger' + self.is_group = 0 self.save() return 1 @@ -38,7 +35,7 @@ class CostCenter(NestedSet): if self.check_gle_exists(): msgprint(_("Cost Center with existing transactions can not be converted to group"), raise_exception=1) else: - self.group_or_ledger = 'Group' + self.is_group = 1 self.save() return 1 @@ -52,7 +49,7 @@ class CostCenter(NestedSet): def validate_budget_details(self): check_acc_list = [] for d in self.get('budgets'): - if self.group_or_ledger=="Group": + if self.is_group==1: msgprint(_("Budget cannot be set for Group Cost Centers"), raise_exception=1) if [d.account, d.fiscal_year] in check_acc_list: @@ -70,7 +67,7 @@ class CostCenter(NestedSet): new_cost_center = get_name_with_abbr(newdn, self.company) # Validate properties before merging - super(CostCenter, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger") + super(CostCenter, self).before_rename(olddn, new_cost_center, merge, "is_group") return new_cost_center diff --git a/erpnext/accounts/doctype/cost_center/test_records.json b/erpnext/accounts/doctype/cost_center/test_records.json index 7486214973..129f0dbaca 100644 --- a/erpnext/accounts/doctype/cost_center/test_records.json +++ b/erpnext/accounts/doctype/cost_center/test_records.json @@ -13,21 +13,21 @@ "cost_center_name": "_Test Cost Center", "distribution_id": "_Test Distribution", "doctype": "Cost Center", - "group_or_ledger": "Ledger", + "is_group": 0, "parent_cost_center": "_Test Company - _TC" }, { "company": "_Test Company", "cost_center_name": "_Test Cost Center 2", "doctype": "Cost Center", - "group_or_ledger": "Ledger", + "is_group": 0, "parent_cost_center": "_Test Company - _TC" }, { "company": "_Test Company", "cost_center_name": "_Test Write Off Cost Center", "doctype": "Cost Center", - "group_or_ledger": "Ledger", + "is_group": 0, "parent_cost_center": "_Test Company - _TC" } ] diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 54acc9e2fb..b17d75bbc2 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -63,10 +63,10 @@ class GLEntry(Document): def validate_account_details(self, adv_adj): """Account must be ledger, active and not freezed""" - ret = frappe.db.sql("""select group_or_ledger, docstatus, company + ret = frappe.db.sql("""select is_group, docstatus, company from tabAccount where name=%s""", self.account, as_dict=1)[0] - if ret.group_or_ledger=='Group': + if ret.is_group==1: frappe.throw(_("Account {0} cannot be a Group").format(self.account)) if ret.docstatus==2: diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 2b0003e210..3a953e743d 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -36,7 +36,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ return { filters: { company: me.frm.doc.company, - group_or_ledger: "Ledger" + is_group: 0 } }; }); diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 0873b9becb..a06e5fc65f 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -546,7 +546,7 @@ def get_payment_entry(doc): def get_opening_accounts(company): """get all balance sheet accounts for opening entry""" accounts = frappe.db.sql_list("""select name from tabAccount - where group_or_ledger='Ledger' and report_type='Balance Sheet' and company=%s""", company) + where is_group=0 and report_type='Balance Sheet' and company=%s""", company) return [{"account": a, "balance": get_balance_on(a)} for a in accounts] diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js index a052375412..10807ff870 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js @@ -5,7 +5,7 @@ cur_frm.set_query("default_account", "accounts", function(doc, cdt, cdn) { return{ filters: [ ['Account', 'account_type', 'in', 'Bank, Cash'], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', 0], ['Account', 'company', '=', doc.company] ] } diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 9394bcb97d..71df6cf0c2 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -22,7 +22,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext return{ filters: { "company": me.frm.doc.company, - "group_or_ledger": "Ledger", + "is_group": 0, "account_type": (me.frm.doc.party_type == "Customer" ? "Receivable" : "Payable") } }; @@ -37,7 +37,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext return{ filters:[ ['Account', 'company', '=', me.frm.doc.company], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', 0], ['Account', 'account_type', 'in', ['Bank', 'Cash']] ] }; diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js index eb441611b1..7224f3ba5a 100644 --- a/erpnext/accounts/doctype/payment_tool/payment_tool.js +++ b/erpnext/accounts/doctype/payment_tool/payment_tool.js @@ -18,7 +18,7 @@ frappe.ui.form.on("Payment Tool", "onload", function(frm) { return { filters: { "account_type": ["in", ["Bank", "Cash"]], - "group_or_ledger": "Ledger", + "is_group": 0, "company": frm.doc.company } } diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js index 2f2fc7caa6..c0875004ea 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js @@ -15,7 +15,7 @@ cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn) "company": doc.company, "report_type": "Balance Sheet", "freeze_account": "No", - "group_or_ledger": "Ledger" + "is_group": 0 } - } + } } diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index 8004e3ee96..db5fec128d 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -22,7 +22,7 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) { return{ filters:{ 'report_type': "Balance Sheet", - 'group_or_ledger': "Ledger", + 'is_group': 0, 'company': doc.company } } @@ -33,7 +33,7 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { return{ filters:{ - 'group_or_ledger': "Ledger", + 'is_group': 0, 'company': doc.company, 'account_type': "Income Account" } @@ -47,7 +47,7 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { return{ filters:{ 'company': doc.company, - 'group_or_ledger': "Ledger" + 'is_group': 0 } } } @@ -60,7 +60,7 @@ cur_frm.fields_dict["expense_account"].get_query = function(doc) { filters: { "report_type": "Profit and Loss", "company": doc.company, - "group_or_ledger": "Ledger" + "is_group": 0 } } } @@ -83,7 +83,7 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) { return{ filters:{ 'report_type': 'Profit and Loss', - 'group_or_ledger': 'Ledger', + 'is_group': 0, 'company': doc.company } } @@ -94,7 +94,7 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) { cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) { return{ filters:{ - 'group_or_ledger': 'Ledger', + 'is_group': 0, 'company': doc.company } } diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 9da83b6359..417e3b307d 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -161,7 +161,7 @@ cur_frm.fields_dict['credit_to'].get_query = function(doc) { filters:{ 'account_type': 'Payable', 'root_type': 'Liability', - 'group_or_ledger': 'Ledger', + 'is_group': 0, 'company': doc.company } } @@ -198,7 +198,7 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function( return { filters: { 'company': doc.company, - 'group_or_ledger': 'Ledger' + 'is_group': 0 } } diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 0e7a640f9a..d2d349e2da 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -394,9 +394,9 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select tabAccount.name from `tabAccount` where (tabAccount.report_type = "Profit and Loss" or tabAccount.account_type in ("Expense Account", "Fixed Asset")) - and tabAccount.group_or_ledger="Ledger" + and tabAccount.is_group=0 and tabAccount.docstatus!=2 and tabAccount.company = '%(company)s' and tabAccount.%(key)s LIKE '%(txt)s' %(mcond)s""" % {'company': filters['company'], 'key': searchfield, - 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)}) \ No newline at end of file + 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)}) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index ade0d32d98..3534cf96e9 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -291,7 +291,7 @@ cur_frm.fields_dict.debit_to.get_query = function(doc) { return{ filters: { 'report_type': 'Balance Sheet', - 'group_or_ledger': 'Ledger', + 'is_group': 0, 'company': doc.company } } @@ -302,7 +302,7 @@ cur_frm.fields_dict.cash_bank_account.get_query = function(doc) { filters: [ ["Account", "account_type", "in", ["Cash", "Bank"]], ["Account", "root_type", "=", "Asset"], - ["Account", "group_or_ledger", "=", "Ledger"], + ["Account", "is_group", "=",0], ["Account", "company", "=", doc.company] ] } @@ -312,7 +312,7 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) { return{ filters:{ 'report_type': 'Profit and Loss', - 'group_or_ledger': 'Ledger', + 'is_group': 0, 'company': doc.company } } @@ -323,7 +323,7 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) { cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) { return{ filters:{ - 'group_or_ledger': 'Ledger', + 'is_group': 0, 'company': doc.company } } @@ -354,7 +354,7 @@ if (sys_defaults.auto_accounting_for_stock) { filters: { 'report_type': 'Profit and Loss', 'company': doc.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } @@ -367,7 +367,7 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function( return { filters: { 'company': doc.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 40712c24cb..55159e4c91 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -449,7 +449,7 @@ class SalesInvoice(SellingController): def make_gl_entries(self, repost_future_gle=True): gl_entries = self.get_gl_entries() - + if gl_entries: from erpnext.accounts.general_ledger import make_gl_entries @@ -617,7 +617,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select tabAccount.name from `tabAccount` where (tabAccount.report_type = "Profit and Loss" or tabAccount.account_type = "Income Account") - and tabAccount.group_or_ledger="Ledger" + and tabAccount.is_group=0 and tabAccount.docstatus!=2 and tabAccount.company = '%(company)s' and tabAccount.%(key)s LIKE '%(txt)s' diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 9c9b037afd..fde7eb2f42 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -24,18 +24,16 @@ frappe.pages["Accounts Browser"].on_page_load = function(wrapper){ '
    '+ '
  1. '+__('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'
  2. '+ '
  3. '+ - __('Accounting Entries can be made against leaf nodes, called')+ - ' ' +__('Ledgers')+'. '+ __('Entries against ') + - '' +__('Groups') + ' '+ __('are not allowed.')+ + __('Accounting Entries can be made against leaf nodes. Entries against Groups are not allowed.')+ '
  4. '+ - '
  5. '+__('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'
  6. '+ + '
  7. '+__('Please do NOT create Accounts for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'
  8. '+ '
  9. '+ ''+__('To create a Bank Account')+': '+ - __('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts and create a new Account Ledger (by clicking on Add Child) of type "Bank"')+ + __('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts and create a new Account (by clicking on Add Child) of type "Bank"')+ '
  10. '+ '
  11. '+ ''+__('To create a Tax Account') +': '+ - __('Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.')+ + __('Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties and create a new Account (by clicking on Add Child) of type "Tax" and do mention the Tax rate.')+ '
  12. '+ '
'+ '

'+__('Please setup your chart of accounts before you start Accounting Entries')+'

').appendTo(main); @@ -201,9 +199,8 @@ erpnext.AccountsChart = Class.extend({ fields: [ {fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true, description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers, they are created automatically from the Customer and Supplier master")}, - {fieldtype:'Select', fieldname:'group_or_ledger', label:__('Group or Ledger'), - options:'Group\nLedger', "default": "Ledger", - description: __('Further accounts can be made under Groups, but entries can be made against Ledger')}, + {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'), + description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')}, {fieldtype:'Select', fieldname:'account_type', label:__('Account Type'), options: ['', 'Bank', 'Cash', 'Warehouse', 'Receivable', 'Payable', 'Equity', 'Cost of Goods Sold', 'Fixed Asset', 'Expense Account', @@ -217,8 +214,8 @@ erpnext.AccountsChart = Class.extend({ var fd = d.fields_dict; // account type if ledger - $(fd.group_or_ledger.input).change(function() { - if($(this).val()=='Group') { + $(fd.is_group.input).change(function() { + if($(this).prop("checked")) { $(fd.account_type.wrapper).toggle(false); $(fd.tax_rate.wrapper).toggle(false); $(fd.warehouse.wrapper).toggle(false); @@ -263,11 +260,11 @@ erpnext.AccountsChart = Class.extend({ // show d.on_page_show = function() { - $(fd.group_or_ledger.input).change(); + $(fd.is_group.input).change(); $(fd.account_type.input).change(); } - $(fd.group_or_ledger.input).val("Ledger").change(); + $(fd.is_group.input).prop("checked", false).change(); d.show(); }, @@ -278,8 +275,8 @@ erpnext.AccountsChart = Class.extend({ title:__('New Cost Center'), fields: [ {fieldtype:'Data', fieldname:'cost_center_name', label:__('New Cost Center Name'), reqd:true}, - {fieldtype:'Select', fieldname:'group_or_ledger', label:__('Group or Ledger'), - options:'Group\nLedger', description:__('Further accounts can be made under Groups but entries can be made against Ledger')}, + {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'), + description:__('Further cost centers can be made under Groups but entries can be made against non-Groups')}, {fieldtype:'Button', fieldname:'create_new', label:__('Create New') } ] }); diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.py b/erpnext/accounts/page/accounts_browser/accounts_browser.py index de19d3b133..30d6ee17be 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.py +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.py @@ -21,7 +21,7 @@ def get_children(): # root if args['parent'] in ("Accounts", "Cost Centers"): acc = frappe.db.sql(""" select - name as value, if(group_or_ledger='Group', 1, 0) as expandable + name as value, is_group as expandable from `tab%s` where ifnull(parent_%s,'') = '' and `company` = %s and docstatus<2 @@ -30,7 +30,7 @@ def get_children(): else: # other acc = frappe.db.sql("""select - name as value, if(group_or_ledger='Group', 1, 0) as expandable + name as value, is_group as expandable from `tab%s` where ifnull(parent_%s,'') = %s and docstatus<2 diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index a9ac72fe8f..ef373aaf29 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -265,7 +265,7 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ var me= this; $.each(this.data, function(i, account) { // update groups - if((account.group_or_ledger == "Ledger") || (account.rgt - account.lft == 1)) { + if((account.is_group == 0) || (account.rgt - account.lft == 1)) { var parent = me.parent_map[account.name]; while(parent) { var parent_account = me.item_by_name[parent]; diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 3bde399b3a..5512c6dfa6 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -188,17 +188,6 @@ class ReceivablePayableReport(object): conditions.append("party_type=%s and party=%s") values += [party_type, self.filters.get(party_type_field)] - if self.filters.account: - conditions.append("account=%s") - values.append(self.filters.account) - else: - account_map = self.get_account_map() - if not account_map: - frappe.throw(_("No Customer Accounts found.")) - else: - conditions.append("account in ({0})".format(", ".join(["%s"] * len(account_map)))) - values += account_map.keys() - return " and ".join(conditions), values def get_gl_entries_for(self, party, party_type, against_voucher_type, against_voucher): diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js index 35a4fe926f..37d81307ad 100644 --- a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js +++ b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.js @@ -24,13 +24,13 @@ frappe.query_reports["Bank Clearance Summary"] = { "reqd": 1, "get_query": function() { return { - "query": "erpnext.controllers.queries.get_account_list", + "query": "erpnext.controllers.queries.get_account_list", "filters": [ ['Account', 'account_type', 'in', 'Bank, Cash'], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', 0], ] } } }, ] -} \ No newline at end of file +} diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js index 0d333da813..581531b298 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js @@ -14,7 +14,7 @@ frappe.query_reports["Bank Reconciliation Statement"] = { "query": "erpnext.controllers.queries.get_account_list", "filters": [ ['Account', 'account_type', 'in', 'Bank, Cash'], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', 0], ] } } diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index e70f2ea39a..a7ee7c0a97 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -8,7 +8,7 @@ from frappe import _ def execute(filters=None): account_details = {} - for acc in frappe.db.sql("""select name, group_or_ledger from tabAccount""", as_dict=1): + for acc in frappe.db.sql("""select name, is_group from tabAccount""", as_dict=1): account_details.setdefault(acc.name, acc) validate_filters(filters, account_details) @@ -25,7 +25,7 @@ def validate_filters(filters, account_details): frappe.throw(_("Account {0} does not exists").format(filters.account)) if filters.get("account") and filters.get("group_by_account") \ - and account_details[filters.account].group_or_ledger == "Ledger": + and account_details[filters.account].is_group == 0: frappe.throw(_("Can not filter based on Account, if grouped by Account")) if filters.get("voucher_no") and filters.get("group_by_voucher"): @@ -45,10 +45,10 @@ def validate_party(filters): frappe.throw(_("Invalid {0}: {1}").format(party_type, party)) def get_columns(): - return [_("Posting Date") + ":Date:90", _("Account") + ":Link/Account:200", - _("Debit") + ":Float:100", _("Credit") + ":Float:100", - _("Voucher Type") + "::120", _("Voucher No") + ":Dynamic Link/Voucher Type:160", - _("Against Account") + "::120", _("Party Type") + "::80", _("Party") + "::150", + return [_("Posting Date") + ":Date:90", _("Account") + ":Link/Account:200", + _("Debit") + ":Float:100", _("Credit") + ":Float:100", + _("Voucher Type") + "::120", _("Voucher No") + ":Dynamic Link/Voucher Type:160", + _("Against Account") + "::120", _("Party Type") + "::80", _("Party") + "::150", _("Cost Center") + ":Link/Cost Center:100", _("Remarks") + "::400"] def get_result(filters, account_details): @@ -179,7 +179,7 @@ def get_result_as_list(data): for d in data: result.append([d.get("posting_date"), d.get("account"), d.get("debit"), d.get("credit"), d.get("voucher_type"), d.get("voucher_no"), - d.get("against"), d.get("party_type"), d.get("party"), + d.get("against"), d.get("party_type"), d.get("party"), d.get("cost_center"), d.get("remarks")]) return result diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 4b5b5f65c5..d00b5dc522 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -89,7 +89,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None): % year_start_date) # different filter for group and ledger - improved performance - if acc.group_or_ledger=="Group": + if acc.is_group: cond.append("""exists ( select * from `tabAccount` ac where ac.name = gle.account and ac.lft >= %s and ac.rgt <= %s diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index a8ccf325fe..064fac1025 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -65,7 +65,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d filters: { 'account_type': 'Payable', 'company': d.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 2af87384ba..898dd23b34 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -138,7 +138,7 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters): tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount where tabAccount.docstatus!=2 and account_type in (%s) - and group_or_ledger = 'Ledger' + and is_group = 0 and company = %s and `%s` LIKE %s limit %s, %s""" % @@ -147,7 +147,7 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters): start, page_len])) if not tax_accounts: tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount - where tabAccount.docstatus!=2 and group_or_ledger = 'Ledger' + where tabAccount.docstatus!=2 and is_group = 0 and company = %s and `%s` LIKE %s limit %s, %s""" % ("%s", searchfield, "%s", "%s", "%s"), (filters.get("company"), "%%%s%%" % txt, start, page_len)) @@ -281,8 +281,8 @@ def get_account_list(doctype, txt, searchfield, start, page_len, filters): elif isinstance(filters, list): filter_list.extend(filters) - if "group_or_ledger" not in [d[1] for d in filter_list]: - filter_list.append(["Account", "group_or_ledger", "=", "Ledger"]) + if "is_group" not in [d[1] for d in filter_list]: + filter_list.append(["Account", "is_group", "=", "0"]) if searchfield and txt: filter_list.append([doctype, searchfield, "like", "%%%s%%" % txt]) diff --git a/erpnext/manufacturing/report/open_production_orders/open_production_orders.json b/erpnext/manufacturing/report/open_production_orders/open_production_orders.json index bb32326463..860f81d871 100644 --- a/erpnext/manufacturing/report/open_production_orders/open_production_orders.json +++ b/erpnext/manufacturing/report/open_production_orders/open_production_orders.json @@ -5,12 +5,12 @@ "doctype": "Report", "idx": 1, "is_standard": "Yes", - "modified": "2015-03-30 05:43:59.976254", + "modified": "2015-04-23 03:26:35.711681", "modified_by": "Administrator", "module": "Manufacturing", "name": "Open Production Orders", "owner": "Administrator", - "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\",\n `tabProduction Order`.company as \"Company:Link/Company:\",\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND NOT EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ", + "query": "SELECT\n `tabProduction Order`.name as \"Production Order:Link/Production Order:200\",\n `tabProduction Order`.creation as \"Date:Date:120\",\n `tabProduction Order`.production_item as \"Item:Link/Item:150\",\n `tabProduction Order`.qty as \"To Produce:Int:100\",\n `tabProduction Order`.produced_qty as \"Produced:Int:100\",\n `tabProduction Order`.company as \"Company:Link/Company:\"\nFROM\n `tabProduction Order`\nWHERE\n `tabProduction Order`.docstatus=1\n AND ifnull(`tabProduction Order`.produced_qty,0) < `tabProduction Order`.qty\n AND NOT EXISTS (SELECT name from `tabStock Entry` where production_order =`tabProduction Order`.name) ", "ref_doctype": "Production Order", "report_name": "Open Production Orders", "report_type": "Query Report" diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0665df4ab1..042bbde291 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -101,6 +101,7 @@ execute:frappe.reload_doc('crm', 'doctype', 'lead') execute:frappe.reload_doc('crm', 'doctype', 'opportunity') erpnext.patches.v5_0.rename_table_fieldnames execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''") +erpnext.patches.v5_0.is_group erpnext.patches.v4_2.party_model erpnext.patches.v5_0.party_model_patch_fix erpnext.patches.v4_1.fix_jv_remarks diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py index bb4ff0bf2c..897598fd29 100644 --- a/erpnext/patches/v4_2/party_model.py +++ b/erpnext/patches/v4_2/party_model.py @@ -25,7 +25,7 @@ def create_receivable_payable_account(): def _create_account(args): account = frappe.new_doc("Account") - account.group_or_ledger = "Ledger" + account.is_group = 0 account.update(args) account.insert() @@ -87,7 +87,7 @@ def set_party_in_jv_and_gl_entry(receivable_payable_accounts): frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt), (new_account, account_details.get("master_type"), account_details.get("master_name"), d.name)) - + if i%500 == 0: frappe.db.commit() diff --git a/erpnext/patches/v5_0/is_group.py b/erpnext/patches/v5_0/is_group.py new file mode 100644 index 0000000000..4e3f760bed --- /dev/null +++ b/erpnext/patches/v5_0/is_group.py @@ -0,0 +1,9 @@ +from __future__ import unicode_literals + +import frappe + +def execute(): + frappe.reload_doctype("Account") + frappe.reload_doctype("Cost Center") + frappe.db.sql("update tabAccount set is_group = if(group_or_ledger='Group', 1, 0)") + frappe.db.sql("update `tabCost Center` set is_group = if(group_or_ledger='Group', 1, 0)") diff --git a/erpnext/public/js/account_tree_grid.js b/erpnext/public/js/account_tree_grid.js index ed3704a81b..ac8784dbac 100644 --- a/erpnext/public/js/account_tree_grid.js +++ b/erpnext/public/js/account_tree_grid.js @@ -178,7 +178,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({ var me= this; $.each(this.data, function(i, account) { // update groups - if((account.group_or_ledger == "Ledger") || (account.rgt - account.lft == 1)) { + if((account.is_group == 0) || (account.rgt - account.lft == 1)) { var parent = me.parent_map[account.name]; while(parent) { var parent_account = me.item_by_name[parent]; diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 5d779fa81c..2ea4bacc4c 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -162,7 +162,7 @@ frappe.ui.form.on(cur_frm.doctype, "onload", function(frm) { return { filters: { 'company': doc.company, - 'group_or_ledger': "Ledger" + "is_group": 0 } } }); diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index b87d7c0627..d83628da24 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -93,7 +93,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d filters: { 'account_type': 'Receivable', 'company': d.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 5ff256dce4..115fdfaf63 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -114,7 +114,7 @@ cur_frm.fields_dict.default_bank_account.get_query = function(doc) { return{ filters: [ ['Account', 'account_type', '=', 'Bank'], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', 0], ['Account', 'company', '=', doc.name] ] } @@ -124,7 +124,7 @@ cur_frm.fields_dict.default_cash_account.get_query = function(doc) { return{ filters: [ ['Account', 'account_type', '=', 'Cash'], - ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'is_group', '=', 0], ['Account', 'company', '=', doc.name] ] } @@ -134,7 +134,7 @@ cur_frm.fields_dict.default_receivable_account.get_query = function(doc) { return{ filters:{ 'company': doc.name, - 'group_or_ledger': "Ledger", + "is_group": 0, "account_type": "Receivable" } } @@ -144,7 +144,7 @@ cur_frm.fields_dict.default_payable_account.get_query = function(doc) { return{ filters:{ 'company': doc.name, - 'group_or_ledger': "Ledger", + "is_group": 0, "account_type": "Payable" } } @@ -156,7 +156,7 @@ cur_frm.fields_dict.default_expense_account.get_query = function(doc) { return{ filters:{ 'company': doc.name, - 'group_or_ledger': "Ledger", + "is_group": 0, "report_type": "Profit and Loss" } } @@ -166,7 +166,7 @@ cur_frm.fields_dict.default_income_account.get_query = function(doc) { return{ filters:{ 'company': doc.name, - 'group_or_ledger': "Ledger", + "is_group": 0, "report_type": "Profit and Loss" } } @@ -176,7 +176,7 @@ cur_frm.fields_dict.cost_center.get_query = function(doc) { return{ filters:{ 'company': doc.name, - 'group_or_ledger': "Ledger", + "is_group": 0, } } } @@ -187,7 +187,7 @@ if (sys_defaults.auto_accounting_for_stock) { "filters": { "report_type": "Profit and Loss", "company": doc.name, - 'group_or_ledger': "Ledger" + "is_group": 0 } } } @@ -200,7 +200,7 @@ if (sys_defaults.auto_accounting_for_stock) { "filters": { "report_type": "Balance Sheet", "company": doc.name, - 'group_or_ledger': "Ledger" + "is_group": 0 } } } diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index a89fc51161..26a2797cc9 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -55,7 +55,7 @@ class Company(Document): self.create_default_warehouses() self.install_country_fixtures() - if not frappe.db.get_value("Cost Center", {"group_or_ledger": "Ledger", "company": self.name}): + if not frappe.db.get_value("Cost Center", {"is_group": 0, "company": self.name}): self.create_default_cost_center() self.set_default_accounts() @@ -71,7 +71,7 @@ class Company(Document): for whname in (_("Stores"), _("Work In Progress"), _("Finished Goods")): if not frappe.db.exists("Warehouse", whname + " - " + self.abbr): stock_group = frappe.db.get_value("Account", {"account_type": "Stock", - "group_or_ledger": "Group", "company": self.name}) + "is_group": 1, "company": self.name}) if stock_group: frappe.get_doc({ "doctype":"Warehouse", @@ -125,7 +125,7 @@ class Company(Document): return account = frappe.db.get_value("Account", {"account_type": account_type, - "group_or_ledger": "Ledger", "company": self.name}) + "is_group": 0, "company": self.name}) if account: self.db_set(fieldname, account) @@ -135,13 +135,13 @@ class Company(Document): { 'cost_center_name': self.name, 'company':self.name, - 'group_or_ledger':'Group', + 'is_group': 1, 'parent_cost_center':None }, { 'cost_center_name':_('Main'), 'company':self.name, - 'group_or_ledger':'Ledger', + 'is_group':0, 'parent_cost_center':self.name + ' - ' + self.abbr }, ] diff --git a/erpnext/setup/doctype/customer_group/customer_group.js b/erpnext/setup/doctype/customer_group/customer_group.js index 8e311197a8..7a5d2fa9dd 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.js +++ b/erpnext/setup/doctype/customer_group/customer_group.js @@ -32,7 +32,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d filters: { 'account_type': 'Receivable', 'company': d.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 15a3781a88..87a10430ac 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -394,7 +394,7 @@ class EmailDigest(Document): if not hasattr(self, "accounts"): self.accounts = frappe.db.sql("""select name, account_type, account_name, root_type from `tabAccount` where company=%s and docstatus < 2 - and group_or_ledger = "Ledger" order by lft""", + and is_group = 0 order by lft""", (self.company,), as_dict=1) return self.accounts diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.js b/erpnext/setup/doctype/supplier_type/supplier_type.js index 7b2464b82d..f1c5d70640 100644 --- a/erpnext/setup/doctype/supplier_type/supplier_type.js +++ b/erpnext/setup/doctype/supplier_type/supplier_type.js @@ -11,7 +11,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d filters: { 'account_type': 'Payable', 'company': d.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index 7fd35425c2..b80d55e7da 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -297,14 +297,14 @@ def create_taxes(args): try: tax_group = frappe.db.get_value("Account", {"company": args.get("company_name"), - "group_or_ledger": "Group", "account_type": "Tax", "root_type": "Liability"}) + "is_group": 1, "account_type": "Tax", "root_type": "Liability"}) if tax_group: frappe.get_doc({ "doctype":"Account", "company": args.get("company_name").strip(), "parent_account": tax_group, "account_name": args.get("tax_" + str(i)), - "group_or_ledger": "Ledger", + "is_group": 0, "report_type": "Balance Sheet", "account_type": "Tax", "tax_rate": flt(tax_rate) if tax_rate else None @@ -330,69 +330,78 @@ def create_items(args): "company": args.get("company_name").strip() }) - frappe.get_doc({ - "doctype":"Item", - "item_code": item, - "item_name": item, - "description": item, - "is_sales_item": "Yes" if is_sales_item else "No", - "is_purchase_item": "Yes" if is_purchase_item else "No", - "show_in_website": 1, - "is_stock_item": is_stock_item and "Yes" or "No", - "item_group": item_group, - "stock_uom": args.get("item_uom_" + str(i)), - "default_warehouse": default_warehouse - }).insert() + try: + frappe.get_doc({ + "doctype":"Item", + "item_code": item, + "item_name": item, + "description": item, + "is_sales_item": "Yes" if is_sales_item else "No", + "is_purchase_item": "Yes" if is_purchase_item else "No", + "show_in_website": 1, + "is_stock_item": is_stock_item and "Yes" or "No", + "item_group": item_group, + "stock_uom": args.get("item_uom_" + str(i)), + "default_warehouse": default_warehouse + }).insert() - if args.get("item_img_" + str(i)): - item_image = args.get("item_img_" + str(i)).split(",") - if len(item_image)==3: - filename, filetype, content = item_image - fileurl = save_file(filename, content, "Item", item, decode=True).file_url - frappe.db.set_value("Item", item, "image", fileurl) + if args.get("item_img_" + str(i)): + item_image = args.get("item_img_" + str(i)).split(",") + if len(item_image)==3: + filename, filetype, content = item_image + fileurl = save_file(filename, content, "Item", item, decode=True).file_url + frappe.db.set_value("Item", item, "image", fileurl) + except frappe.NameError: + pass def create_customers(args): for i in xrange(1,6): customer = args.get("customer_" + str(i)) if customer: - frappe.get_doc({ - "doctype":"Customer", - "customer_name": customer, - "customer_type": "Company", - "customer_group": _("Commercial"), - "territory": args.get("country"), - "company": args.get("company_name").strip() - }).insert() - - if args.get("customer_contact_" + str(i)): - contact = args.get("customer_contact_" + str(i)).split(" ") + try: frappe.get_doc({ - "doctype":"Contact", - "customer": customer, - "first_name":contact[0], - "last_name": len(contact) > 1 and contact[1] or "" + "doctype":"Customer", + "customer_name": customer, + "customer_type": "Company", + "customer_group": _("Commercial"), + "territory": args.get("country"), + "company": args.get("company_name").strip() }).insert() + if args.get("customer_contact_" + str(i)): + contact = args.get("customer_contact_" + str(i)).split(" ") + frappe.get_doc({ + "doctype":"Contact", + "customer": customer, + "first_name":contact[0], + "last_name": len(contact) > 1 and contact[1] or "" + }).insert() + except frappe.NameError: + pass + def create_suppliers(args): for i in xrange(1,6): supplier = args.get("supplier_" + str(i)) if supplier: - frappe.get_doc({ - "doctype":"Supplier", - "supplier_name": supplier, - "supplier_type": _("Local"), - "company": args.get("company_name").strip() - }).insert() - - if args.get("supplier_contact_" + str(i)): - contact = args.get("supplier_contact_" + str(i)).split(" ") + try: frappe.get_doc({ - "doctype":"Contact", - "supplier": supplier, - "first_name":contact[0], - "last_name": len(contact) > 1 and contact[1] or "" + "doctype":"Supplier", + "supplier_name": supplier, + "supplier_type": _("Local"), + "company": args.get("company_name").strip() }).insert() + if args.get("supplier_contact_" + str(i)): + contact = args.get("supplier_contact_" + str(i)).split(" ") + frappe.get_doc({ + "doctype":"Contact", + "supplier": supplier, + "first_name":contact[0], + "last_name": len(contact) > 1 and contact[1] or "" + }).insert() + except frappe.NameError: + pass + def create_letter_head(args): if args.get("attach_letterhead"): diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index 813090f2c9..b8653cd9c6 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -19,7 +19,7 @@ data_map = { # Accounts "Account": { "columns": ["name", "parent_account", "lft", "rgt", "report_type", - "company", "group_or_ledger"], + "company", "is_group"], "conditions": ["docstatus < 2"], "order_by": "lft", "links": { diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 00916c27ee..631009fa08 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -214,7 +214,7 @@ if (sys_defaults.auto_accounting_for_stock) { filters: { "report_type": "Profit and Loss", "company": doc.company, - "group_or_ledger": "Ledger" + "is_group": 0 } } } @@ -236,7 +236,7 @@ if (sys_defaults.auto_accounting_for_stock) { filters: { 'company': doc.company, - 'group_or_ledger': "Ledger" + "is_group": 0 } } } diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 24851dd2e9..55d6d33ce7 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -122,7 +122,7 @@ $.extend(erpnext.item, { return { filters: { "report_type": "Profit and Loss", - "group_or_ledger": "Ledger" + "is_group": 0 } } } @@ -133,7 +133,7 @@ $.extend(erpnext.item, { return { filters: { "report_type": "Profit and Loss", - 'group_or_ledger': "Ledger", + "is_group": 0, 'account_type': "Income Account" } } @@ -144,7 +144,7 @@ $.extend(erpnext.item, { // ----------------------------- frm.fields_dict['buying_cost_center'].get_query = function(doc) { return { - filters:{ 'group_or_ledger': "Ledger" } + filters:{ "is_group": 0 } } } @@ -153,7 +153,7 @@ $.extend(erpnext.item, { // ----------------------------- frm.fields_dict['selling_cost_center'].get_query = function(doc) { return { - filters:{ 'group_or_ledger': "Ledger" } + filters:{ "is_group": 0 } } } diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index c7c7aaad10..6bb2e2f4ff 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -51,7 +51,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ return { filters: { "company": me.frm.doc.company, - "group_or_ledger": "Ledger" + "is_group": 0 } } } diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index 67eb882423..c0ae213b87 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -65,7 +65,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ return { "filters": { 'company': me.frm.doc.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } @@ -73,7 +73,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ return { "filters": { 'company': me.frm.doc.company, - 'group_or_ledger': 'Ledger' + "is_group": 0 } } } diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index 27b63b5c24..22396b762e 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -9,7 +9,7 @@ cur_frm.set_query("create_account_under", function() { return { filters: { "company": cur_frm.doc.company, - 'group_or_ledger': "Group" + 'is_group': 1 } } }) diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py index 1643f93904..2024ebe2d4 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.py +++ b/erpnext/stock/doctype/warehouse/warehouse.py @@ -48,7 +48,7 @@ class Warehouse(Document): "doctype": "Account", 'account_name': self.warehouse_name, 'parent_account': self.create_account_under, - 'group_or_ledger':'Ledger', + 'is_group':0, 'company':self.company, "account_type": "Warehouse", "warehouse": self.name,