[rename] group_or_ledger to is_group

This commit is contained in:
Rushabh Mehta 2015-04-23 13:14:17 +05:30
parent 4669fe3e85
commit 38c6b52770
56 changed files with 295 additions and 305 deletions

View File

@ -12,12 +12,12 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_display('account_name', doc.__islocal); cur_frm.toggle_display('account_name', doc.__islocal);
// hide fields if group // 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 // 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); 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.add_fetch('parent_account', 'root_type', 'root_type');
cur_frm.cscript.account_type = function(doc, cdt, cdn) { 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(['tax_rate'], doc.account_type == 'Tax');
cur_frm.toggle_display('warehouse', doc.account_type=='Warehouse'); 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'), cur_frm.add_custom_button(__('Chart of Accounts'),
function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap') function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
if (cstr(doc.group_or_ledger) == 'Group') { if (doc.is_group == 1) {
cur_frm.add_custom_button(__('Convert to Ledger'), cur_frm.add_custom_button(__('Convert to non-Group'),
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet', 'btn-default'); 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() { cur_frm.add_custom_button(__('View Ledger'), function() {
frappe.route_options = { frappe.route_options = {
"account": doc.name, "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) { cur_frm.fields_dict['parent_account'].get_query = function(doc) {
return { return {
filters: { filters: {
"group_or_ledger": "Group", "is_group": 1,
"company": doc.company "company": doc.company
} }
} }

View File

@ -38,18 +38,12 @@
"search_index": 1 "search_index": 1
}, },
{ {
"default": "Ledger", "default": "0",
"fieldname": "group_or_ledger", "fieldname": "is_group",
"fieldtype": "Select", "fieldtype": "Check",
"in_filter": 1, "label": "Is Group",
"in_list_view": 1,
"label": "Group or Ledger",
"oldfieldname": "group_or_ledger",
"oldfieldtype": "Select",
"options": "\nLedger\nGroup",
"permlevel": 0, "permlevel": 0,
"read_only": 1, "precision": "",
"reqd": 1,
"search_index": 1 "search_index": 1
}, },
{ {
@ -177,7 +171,7 @@
"icon": "icon-money", "icon": "icon-money",
"idx": 1, "idx": 1,
"in_create": 0, "in_create": 0,
"modified": "2015-02-20 05:09:22.108350", "modified": "2015-04-23 02:53:48.056520",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Account", "name": "Account",
@ -261,5 +255,5 @@
"write": 1 "write": 1
} }
], ],
"search_fields": "group_or_ledger" "search_fields": "is_group"
} }

View File

@ -32,12 +32,12 @@ class Account(Document):
"""Fetch Parent Details and validate parent account""" """Fetch Parent Details and validate parent account"""
if self.parent_account: if self.parent_account:
par = frappe.db.get_value("Account", 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: if not par:
throw(_("Account {0}: Parent account {1} does not exist").format(self.name, self.parent_account)) throw(_("Account {0}: Parent account {1} does not exist").format(self.name, self.parent_account))
elif par.name == self.name: elif par.name == self.name:
throw(_("Account {0}: You can not assign itself as parent account").format(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)) throw(_("Account {0}: Parent account {1} can not be a ledger").format(self.name, self.parent_account))
elif par.company != self.company: elif par.company != self.company:
throw(_("Account {0}: Parent account {1} does not belong to company: {2}") throw(_("Account {0}: Parent account {1} does not belong to company: {2}")
@ -78,7 +78,7 @@ class Account(Document):
elif self.check_gle_exists(): elif self.check_gle_exists():
throw(_("Account with existing transaction cannot be converted to ledger")) throw(_("Account with existing transaction cannot be converted to ledger"))
else: else:
self.group_or_ledger = 'Ledger' self.is_group = 0
self.save() self.save()
return 1 return 1
@ -88,7 +88,7 @@ class Account(Document):
elif self.account_type: elif self.account_type:
throw(_("Cannot covert to Group because Account Type is selected.")) throw(_("Cannot covert to Group because Account Type is selected."))
else: else:
self.group_or_ledger = 'Group' self.is_group = 1
self.save() self.save()
return 1 return 1
@ -160,10 +160,10 @@ class Account(Document):
throw(_("Account {0} does not exist").format(new)) throw(_("Account {0} does not exist").format(new))
val = list(frappe.db.get_value("Account", new_account, 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]: if val != [self.is_group, self.root_type, self.company]:
throw(_("""Merging is only possible if following properties are same in both records. Group or Ledger, Root Type, Company""")) throw(_("""Merging is only possible if following properties are same in both records. Is Group, Root Type, Company"""))
return new_account return new_account
@ -177,7 +177,7 @@ class Account(Document):
def get_parent_account(doctype, txt, searchfield, start, page_len, filters): def get_parent_account(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select name from tabAccount 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""" % and %s like %s order by name limit %s, %s""" %
("%s", searchfield, "%s", "%s", "%s"), ("%s", searchfield, "%s", "%s", "%s"),
(filters["company"], "%%%s%%" % txt, start, page_len), as_list=1) (filters["company"], "%%%s%%" % txt, start, page_len), as_list=1)

View File

@ -13,18 +13,18 @@ def create_charts(chart_name, company):
accounts = [] accounts = []
def _import_accounts(children, parent, root_type, root_account=False): 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: 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()) account_name_in_db = unidecode(account_name.strip().lower())
if account_name_in_db in accounts: if account_name_in_db in accounts:
count = accounts.count(account_name_in_db) count = accounts.count(account_name_in_db)
account_name = account_name + " " + cstr(count) 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"] \ report_type = "Balance Sheet" if root_type in ["Asset", "Liability", "Equity"] \
else "Profit and Loss" else "Profit and Loss"
@ -33,10 +33,10 @@ def create_charts(chart_name, company):
"account_name": account_name, "account_name": account_name,
"company": company, "company": company,
"parent_account": parent, "parent_account": parent,
"group_or_ledger": group_or_ledger, "is_group": is_group,
"root_type": root_type, "root_type": root_type,
"report_type": report_type, "report_type": report_type,
"account_type": children.get("account_type") "account_type": child.get("account_type")
}) })
if root_account: if root_account:
@ -46,19 +46,19 @@ def create_charts(chart_name, company):
accounts.append(account_name_in_db) 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) _import_accounts(chart, None, None, root_account=True)
def identify_group_or_ledger(children): def identify_is_group(child):
if children.get("group_or_ledger"): if child.get("is_group"):
group_or_ledger = children.get("group_or_ledger") is_group = child.get("is_group")
elif len(set(children.keys()) - set(["account_type", "root_type", "group_or_ledger"])): elif len(set(child.keys()) - set(["account_type", "root_type", "is_group"])):
group_or_ledger = "Group" is_group = 1
else: else:
group_or_ledger = "Ledger" is_group = 0
return group_or_ledger return is_group
def get_chart(chart_name): def get_chart(chart_name):
chart = {} chart = {}

View File

@ -85,7 +85,7 @@
}, },
"Stock in Hand": { "Stock in Hand": {
"account_type": "Stock", "account_type": "Stock",
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Perliminary and Preoperating Expenses": { "Perliminary and Preoperating Expenses": {
@ -326,7 +326,7 @@
}, },
"Duties and Taxes": { "Duties and Taxes": {
"account_type": "Tax", "account_type": "Tax",
"group_or_ledger": "Group" "is_group": 1
}, },
"Accruals & Provisions": { "Accruals & Provisions": {
"Accruals": { "Accruals": {

View File

@ -12,7 +12,7 @@
}, },
"Bank Accounts": { "Bank Accounts": {
"account_type": "Bank", "account_type": "Bank",
"group_or_ledger": "Group" "is_group": 1
}, },
"Cash In Hand": { "Cash In Hand": {
"Cash": { "Cash": {
@ -21,17 +21,17 @@
"account_type": "Cash" "account_type": "Cash"
}, },
"Loans and Advances (Assets)": { "Loans and Advances (Assets)": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Securities and Deposits": { "Securities and Deposits": {
"Earnest Money": {} "Earnest Money": {}
}, },
"Stock Assets": { "Stock Assets": {
"account_type": "Stock", "account_type": "Stock",
"group_or_ledger": "Group" "is_group": 1
}, },
"Tax Assets": { "Tax Assets": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Fixed Assets": { "Fixed Assets": {
@ -52,7 +52,7 @@
} }
}, },
"Investments": { "Investments": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Temporary Accounts (Assets)": { "Temporary Accounts (Assets)": {
"Temporary Assets": {} "Temporary Assets": {}
@ -146,7 +146,7 @@
}, },
"Indirect Income": { "Indirect Income": {
"account_type": "Income Account", "account_type": "Income Account",
"group_or_ledger": "Group" "is_group": 1
}, },
"root_type": "Income" "root_type": "Income"
}, },
@ -168,7 +168,7 @@
}, },
"Duties and Taxes": { "Duties and Taxes": {
"account_type": "Tax", "account_type": "Tax",
"group_or_ledger": "Group" "is_group": 1
}, },
"Loans (Liabilities)": { "Loans (Liabilities)": {
"Secured Loans": {}, "Secured Loans": {},

View File

@ -32,7 +32,7 @@
} }
}, },
"Otros Equivalentes a Efectivo": { "Otros Equivalentes a Efectivo": {
"group_or_ledger": "Group", "is_group": 1,
"account_type": "Cash" "account_type": "Cash"
} }
}, },
@ -61,7 +61,7 @@
"Estimacion para Cuentas Incobrables": {} "Estimacion para Cuentas Incobrables": {}
}, },
"Inventarios": { "Inventarios": {
"group_or_ledger": "Group", "is_group": 1,
"account_type": "Stock" "account_type": "Stock"
}, },
"Impuestos Acreditables": { "Impuestos Acreditables": {
@ -90,7 +90,7 @@
"Retenciones Definitivas Sobre Rentas o Ganancias de Capital": {} "Retenciones Definitivas Sobre Rentas o Ganancias de Capital": {}
}, },
"Otras Cuentas por Cobrar": { "Otras Cuentas por Cobrar": {
"group_or_ledger": "Group", "is_group": 1,
"account_type": "Receivable" "account_type": "Receivable"
} }
}, },
@ -110,11 +110,11 @@
}, },
"Inversiones Permanentes": { "Inversiones Permanentes": {
"Inversiones Permanentes": { "Inversiones Permanentes": {
"group_or_ledger": "Group", "is_group": 1,
"account_type": "Fixed Asset" "account_type": "Fixed Asset"
}, },
"Negocios Conjuntos": { "Negocios Conjuntos": {
"group_or_ledger": "Group", "is_group": 1,
"account_type": "Fixed Asset" "account_type": "Fixed Asset"
} }
}, },
@ -124,25 +124,25 @@
}, },
"Activos Intangibles": { "Activos Intangibles": {
"Patentes": { "Patentes": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Marcas Registradas": { "Marcas Registradas": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Derechos de Autor": { "Derechos de Autor": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Concesiones": { "Concesiones": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Licencias": { "Licencias": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Gastos de investigacion": { "Gastos de investigacion": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Amortizacion de Activos Intangibles": { "Amortizacion de Activos Intangibles": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Deterioro de Valor de Activos Intangibles": {} "Deterioro de Valor de Activos Intangibles": {}
}, },
@ -150,29 +150,29 @@
"Gastos de Consitucion": {}, "Gastos de Consitucion": {},
"Gastos Pre Operativos": {}, "Gastos Pre Operativos": {},
"Mejoras en Bienes Arrendados": { "Mejoras en Bienes Arrendados": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Amortizacion de Activos Amortizables": {}, "Amortizacion de Activos Amortizables": {},
"Deterioro de Valaor de Activos Amortizables": {} "Deterioro de Valaor de Activos Amortizables": {}
}, },
"Cuentas por Cobrar a Largo Plazo": { "Cuentas por Cobrar a Largo Plazo": {
"Creditos a Largo Plazo": { "Creditos a Largo Plazo": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Inversiones a Largo Plazo": { "Inversiones a Largo Plazo": {
"Depositos Bancarios a Plazo": { "Depositos Bancarios a Plazo": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Intereses percibidos por adelantado": { "Intereses percibidos por adelantado": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Titulos y Acciones": { "Titulos y Acciones": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Activo por Impuestos Diferidos": { "Activo por Impuestos Diferidos": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"root_type": "Asset" "root_type": "Asset"
@ -199,21 +199,21 @@
"Anticipos de Clientes": {}, "Anticipos de Clientes": {},
"Pasivos Financieros a Corto Plazo": { "Pasivos Financieros a Corto Plazo": {
"Prestamos por Pagar a Corto Plazo": { "Prestamos por Pagar a Corto Plazo": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Sobregiros Bancarios": { "Sobregiros Bancarios": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Otras Deudas Bancarias": { "Otras Deudas Bancarias": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Gastos por Pagar": { "Gastos por Pagar": {
"Servicios Basicos": { "Servicios Basicos": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Prestaciones Sociales": { "Prestaciones Sociales": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Salarios por Pagar": {} "Salarios por Pagar": {}
}, },
@ -287,28 +287,28 @@
} }
}, },
"Otras Cuentas por Pagar": { "Otras Cuentas por Pagar": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Pasivo No Corriente": { "Pasivo No Corriente": {
"Prestamos a Largo Plazo": { "Prestamos a Largo Plazo": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Cuentas por Pagar a Largo Plaso": { "Cuentas por Pagar a Largo Plaso": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Otras Cuentas por Pagar a Largo Plazo": { "Otras Cuentas por Pagar a Largo Plazo": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Otros Pasivos Financieros a Largo Plaso": { "Otros Pasivos Financieros a Largo Plaso": {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
"Obligaciones por Arrendamiento Financiero a Largo Plazo": { "Obligaciones por Arrendamiento Financiero a Largo Plazo": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Pasivo por Impuestos Diferidos": { "Pasivo por Impuestos Diferidos": {
"group_or_ledger": "Group" "is_group": 1
}, },
"root_type": "Liability" "root_type": "Liability"
}, },
@ -324,7 +324,7 @@
} }
}, },
"Donaciones": { "Donaciones": {
"group_or_ledger": "Group" "is_group": 1
}, },
"Ganancias Acumuladas": { "Ganancias Acumuladas": {
"Reservas": { "Reservas": {

View File

@ -15,7 +15,7 @@ def get():
}, },
_("Bank Accounts"): { _("Bank Accounts"): {
"account_type": "Bank", "account_type": "Bank",
"group_or_ledger": "Group" "is_group": 1
}, },
_("Cash In Hand"): { _("Cash In Hand"): {
_("Cash"): { _("Cash"): {
@ -24,17 +24,17 @@ def get():
"account_type": "Cash" "account_type": "Cash"
}, },
_("Loans and Advances (Assets)"): { _("Loans and Advances (Assets)"): {
"group_or_ledger": "Group" "is_group": 1
}, },
_("Securities and Deposits"): { _("Securities and Deposits"): {
_("Earnest Money"): {} _("Earnest Money"): {}
}, },
_("Stock Assets"): { _("Stock Assets"): {
"account_type": "Stock", "account_type": "Stock",
"group_or_ledger": "Group" "is_group": 1
}, },
_("Tax Assets"): { _("Tax Assets"): {
"group_or_ledger": "Group" "is_group": 1
} }
}, },
_("Fixed Assets"): { _("Fixed Assets"): {
@ -55,7 +55,7 @@ def get():
} }
}, },
_("Investments"): { _("Investments"): {
"group_or_ledger": "Group" "is_group": 1
}, },
_("Temporary Accounts (Assets)"): { _("Temporary Accounts (Assets)"): {
_("Temporary Assets"): {} _("Temporary Assets"): {}
@ -149,7 +149,7 @@ def get():
}, },
_("Indirect Income"): { _("Indirect Income"): {
"account_type": "Income Account", "account_type": "Income Account",
"group_or_ledger": "Group" "is_group": 1
}, },
"root_type": "Income" "root_type": "Income"
}, },
@ -167,7 +167,7 @@ def get():
}, },
_("Duties and Taxes"): { _("Duties and Taxes"): {
"account_type": "Tax", "account_type": "Tax",
"group_or_ledger": "Group" "is_group": 1
}, },
_("Loans (Liabilities)"): { _("Loans (Liabilities)"): {
_("Secured Loans"): {}, _("Secured Loans"): {},

View File

@ -8,37 +8,37 @@ def _make_test_records(verbose):
from frappe.test_runner import make_test_objects from frappe.test_runner import make_test_objects
accounts = [ accounts = [
# [account_name, parent_account, group_or_ledger] # [account_name, parent_account, is_group]
["_Test Account Bank Account", "Bank Accounts", "Ledger", "Bank"], ["_Test Account Bank Account", "Bank Accounts", 0, "Bank"],
["_Test Account Stock Expenses", "Direct Expenses", "Group", None], ["_Test Account Stock Expenses", "Direct Expenses", 1, None],
["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"], ["_Test Account Shipping Charges", "_Test Account Stock Expenses", 0, "Chargeable"],
["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger", "Tax"], ["_Test Account Customs Duty", "_Test Account Stock Expenses", 0, "Tax"],
["_Test Account Insurance Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"], ["_Test Account Insurance Charges", "_Test Account Stock Expenses", 0, "Chargeable"],
["_Test Account Stock Adjustment", "_Test Account Stock Expenses", "Ledger", "Stock Adjustment"], ["_Test Account Stock Adjustment", "_Test Account Stock Expenses", 0, "Stock Adjustment"],
["_Test Account Tax Assets", "Current Assets", "Group", None], ["_Test Account Tax Assets", "Current Assets", 1, None],
["_Test Account VAT", "_Test Account Tax Assets", "Ledger", "Tax"], ["_Test Account VAT", "_Test Account Tax Assets", 0, "Tax"],
["_Test Account Service Tax", "_Test Account Tax Assets", "Ledger", "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 Cost for Goods Sold", "Expenses", 0, None],
["_Test Account Excise Duty", "_Test Account Tax Assets", "Ledger", "Tax"], ["_Test Account Excise Duty", "_Test Account Tax Assets", 0, "Tax"],
["_Test Account Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"], ["_Test Account Education Cess", "_Test Account Tax Assets", 0, "Tax"],
["_Test Account S&H Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"], ["_Test Account S&H Education Cess", "_Test Account Tax Assets", 0, "Tax"],
["_Test Account CST", "Direct Expenses", "Ledger", "Tax"], ["_Test Account CST", "Direct Expenses", 0, "Tax"],
["_Test Account Discount", "Direct Expenses", "Ledger", None], ["_Test Account Discount", "Direct Expenses", 0, None],
["_Test Write Off", "Indirect Expenses", "Ledger", None], ["_Test Write Off", "Indirect Expenses", 0, None],
# related to Account Inventory Integration # related to Account Inventory Integration
["_Test Account Stock In Hand", "Current Assets", "Ledger", None], ["_Test Account Stock In Hand", "Current Assets", 0, None],
["_Test Account Fixed Assets", "Current Assets", "Ledger", None], ["_Test Account Fixed Assets", "Current Assets", 0, None],
# Receivable / Payable Account # Receivable / Payable Account
["_Test Receivable", "Current Assets", "Ledger", "Receivable"], ["_Test Receivable", "Current Assets", 0, "Receivable"],
["_Test Payable", "Current Liabilities", "Ledger", "Payable"], ["_Test Payable", "Current Liabilities", 0, "Payable"],
] ]
for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]: for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]:
@ -47,8 +47,8 @@ def _make_test_records(verbose):
"account_name": account_name, "account_name": account_name,
"parent_account": parent_account + " - " + abbr, "parent_account": parent_account + " - " + abbr,
"company": company, "company": company,
"group_or_ledger": group_or_ledger, "is_group": is_group,
"account_type": account_type "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 return test_objects

View File

@ -26,7 +26,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
return { return {
"filters": { "filters": {
"account_type": "Bank", "account_type": "Bank",
"group_or_ledger": "Ledger" "is_group": 0
} }
}; };
}); });

View File

@ -18,7 +18,7 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
filters:[ filters:[
['Account', 'company', '=', me.frm.doc.company], ['Account', 'company', '=', me.frm.doc.company],
['Account', 'report_type', '=', 'Profit and Loss'], ['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() { this.frm.set_query("parent_cost_center", function() {
return { return {
filters:[ filters:[
['Cost Center', 'group_or_ledger', '=', 'Group'], ['Cost Center', 'is_group', '=', '1'],
['Cost Center', 'company', '=', me.frm.doc.company], ['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) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {
var intro_txt = ''; var intro_txt = '';
cur_frm.toggle_display('cost_center_name', doc.__islocal); 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.'); 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.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.set_intro(intro_txt);
cur_frm.add_custom_button(__('Chart of Cost Centers'), 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) { cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
if (cstr(doc.group_or_ledger) == 'Group') { if (doc.is_group == 1) {
cur_frm.add_custom_button(__('Convert to Ledger'), cur_frm.add_custom_button(__('Convert to non-Group'),
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet', function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet',
"btn-default") "btn-default")
} else if (cstr(doc.group_or_ledger) == 'Ledger') { } else if (doc.is_group == 0) {
cur_frm.add_custom_button(__('Convert to Group'), cur_frm.add_custom_button(__('Convert to Group'),
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet', function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet',
"btn-default") "btn-default")

View File

@ -58,18 +58,12 @@
"width": "50%" "width": "50%"
}, },
{ {
"fieldname": "group_or_ledger", "default": "0",
"fieldtype": "Select", "fieldname": "is_group",
"hidden": 0, "fieldtype": "Check",
"label": "Group or Ledger", "label": "Is Group",
"no_copy": 1,
"oldfieldname": "group_or_ledger",
"oldfieldtype": "Select",
"options": "\nGroup\nLedger",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "precision": ""
"report_hide": 1,
"reqd": 1
}, },
{ {
"description": "Define Budget for this Cost Center. To set budget action, see <a href=\"#!List/Company\">Company Master</a>", "description": "Define Budget for this Cost Center. To set budget action, see <a href=\"#!List/Company\">Company Master</a>",
@ -145,7 +139,7 @@
"icon": "icon-money", "icon": "icon-money",
"idx": 1, "idx": 1,
"in_create": 0, "in_create": 0,
"modified": "2015-02-20 05:07:59.251051", "modified": "2015-04-23 02:54:26.934607",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Cost Center", "name": "Cost Center",
@ -198,5 +192,5 @@
"role": "Material User" "role": "Material User"
} }
], ],
"search_fields": "parent_cost_center" "search_fields": "parent_cost_center, is_group"
} }

View File

@ -16,9 +16,6 @@ class CostCenter(NestedSet):
frappe.db.get_value("Company", self.company, "abbr") frappe.db.get_value("Company", self.company, "abbr")
def validate_mandatory(self): 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: if self.cost_center_name != self.company and not self.parent_cost_center:
msgprint(_("Please enter parent cost center"), raise_exception=1) msgprint(_("Please enter parent cost center"), raise_exception=1)
elif self.cost_center_name == self.company and self.parent_cost_center: elif self.cost_center_name == self.company and self.parent_cost_center:
@ -30,7 +27,7 @@ class CostCenter(NestedSet):
elif self.check_gle_exists(): elif self.check_gle_exists():
msgprint(_("Cost Center with existing transactions can not be converted to ledger"), raise_exception=1) msgprint(_("Cost Center with existing transactions can not be converted to ledger"), raise_exception=1)
else: else:
self.group_or_ledger = 'Ledger' self.is_group = 0
self.save() self.save()
return 1 return 1
@ -38,7 +35,7 @@ class CostCenter(NestedSet):
if self.check_gle_exists(): if self.check_gle_exists():
msgprint(_("Cost Center with existing transactions can not be converted to group"), raise_exception=1) msgprint(_("Cost Center with existing transactions can not be converted to group"), raise_exception=1)
else: else:
self.group_or_ledger = 'Group' self.is_group = 1
self.save() self.save()
return 1 return 1
@ -52,7 +49,7 @@ class CostCenter(NestedSet):
def validate_budget_details(self): def validate_budget_details(self):
check_acc_list = [] check_acc_list = []
for d in self.get('budgets'): 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) msgprint(_("Budget cannot be set for Group Cost Centers"), raise_exception=1)
if [d.account, d.fiscal_year] in check_acc_list: 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) new_cost_center = get_name_with_abbr(newdn, self.company)
# Validate properties before merging # 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 return new_cost_center

View File

@ -13,21 +13,21 @@
"cost_center_name": "_Test Cost Center", "cost_center_name": "_Test Cost Center",
"distribution_id": "_Test Distribution", "distribution_id": "_Test Distribution",
"doctype": "Cost Center", "doctype": "Cost Center",
"group_or_ledger": "Ledger", "is_group": 0,
"parent_cost_center": "_Test Company - _TC" "parent_cost_center": "_Test Company - _TC"
}, },
{ {
"company": "_Test Company", "company": "_Test Company",
"cost_center_name": "_Test Cost Center 2", "cost_center_name": "_Test Cost Center 2",
"doctype": "Cost Center", "doctype": "Cost Center",
"group_or_ledger": "Ledger", "is_group": 0,
"parent_cost_center": "_Test Company - _TC" "parent_cost_center": "_Test Company - _TC"
}, },
{ {
"company": "_Test Company", "company": "_Test Company",
"cost_center_name": "_Test Write Off Cost Center", "cost_center_name": "_Test Write Off Cost Center",
"doctype": "Cost Center", "doctype": "Cost Center",
"group_or_ledger": "Ledger", "is_group": 0,
"parent_cost_center": "_Test Company - _TC" "parent_cost_center": "_Test Company - _TC"
} }
] ]

View File

@ -63,10 +63,10 @@ class GLEntry(Document):
def validate_account_details(self, adv_adj): def validate_account_details(self, adv_adj):
"""Account must be ledger, active and not freezed""" """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] 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)) frappe.throw(_("Account {0} cannot be a Group").format(self.account))
if ret.docstatus==2: if ret.docstatus==2:

View File

@ -36,7 +36,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
return { return {
filters: { filters: {
company: me.frm.doc.company, company: me.frm.doc.company,
group_or_ledger: "Ledger" is_group: 0
} }
}; };
}); });

View File

@ -546,7 +546,7 @@ def get_payment_entry(doc):
def get_opening_accounts(company): def get_opening_accounts(company):
"""get all balance sheet accounts for opening entry""" """get all balance sheet accounts for opening entry"""
accounts = frappe.db.sql_list("""select name from tabAccount 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] return [{"account": a, "balance": get_balance_on(a)} for a in accounts]

View File

@ -5,7 +5,7 @@ cur_frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
return{ return{
filters: [ filters: [
['Account', 'account_type', 'in', 'Bank, Cash'], ['Account', 'account_type', 'in', 'Bank, Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'is_group', '=', 0],
['Account', 'company', '=', doc.company] ['Account', 'company', '=', doc.company]
] ]
} }

View File

@ -22,7 +22,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
return{ return{
filters: { filters: {
"company": me.frm.doc.company, "company": me.frm.doc.company,
"group_or_ledger": "Ledger", "is_group": 0,
"account_type": (me.frm.doc.party_type == "Customer" ? "Receivable" : "Payable") "account_type": (me.frm.doc.party_type == "Customer" ? "Receivable" : "Payable")
} }
}; };
@ -37,7 +37,7 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
return{ return{
filters:[ filters:[
['Account', 'company', '=', me.frm.doc.company], ['Account', 'company', '=', me.frm.doc.company],
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'is_group', '=', 0],
['Account', 'account_type', 'in', ['Bank', 'Cash']] ['Account', 'account_type', 'in', ['Bank', 'Cash']]
] ]
}; };

View File

@ -18,7 +18,7 @@ frappe.ui.form.on("Payment Tool", "onload", function(frm) {
return { return {
filters: { filters: {
"account_type": ["in", ["Bank", "Cash"]], "account_type": ["in", ["Bank", "Cash"]],
"group_or_ledger": "Ledger", "is_group": 0,
"company": frm.doc.company "company": frm.doc.company
} }
} }

View File

@ -15,7 +15,7 @@ cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn)
"company": doc.company, "company": doc.company,
"report_type": "Balance Sheet", "report_type": "Balance Sheet",
"freeze_account": "No", "freeze_account": "No",
"group_or_ledger": "Ledger" "is_group": 0
} }
} }
} }

View File

@ -22,7 +22,7 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) {
return{ return{
filters:{ filters:{
'report_type': "Balance Sheet", 'report_type': "Balance Sheet",
'group_or_ledger': "Ledger", 'is_group': 0,
'company': doc.company '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) { cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
return{ return{
filters:{ filters:{
'group_or_ledger': "Ledger", 'is_group': 0,
'company': doc.company, 'company': doc.company,
'account_type': "Income Account" 'account_type': "Income Account"
} }
@ -47,7 +47,7 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
return{ return{
filters:{ filters:{
'company': doc.company, '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: { filters: {
"report_type": "Profit and Loss", "report_type": "Profit and Loss",
"company": doc.company, "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{ return{
filters:{ filters:{
'report_type': 'Profit and Loss', 'report_type': 'Profit and Loss',
'group_or_ledger': 'Ledger', 'is_group': 0,
'company': doc.company '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) { cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
return{ return{
filters:{ filters:{
'group_or_ledger': 'Ledger', 'is_group': 0,
'company': doc.company 'company': doc.company
} }
} }

View File

@ -161,7 +161,7 @@ cur_frm.fields_dict['credit_to'].get_query = function(doc) {
filters:{ filters:{
'account_type': 'Payable', 'account_type': 'Payable',
'root_type': 'Liability', 'root_type': 'Liability',
'group_or_ledger': 'Ledger', 'is_group': 0,
'company': doc.company 'company': doc.company
} }
} }
@ -198,7 +198,7 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(
return { return {
filters: { filters: {
'company': doc.company, 'company': doc.company,
'group_or_ledger': 'Ledger' 'is_group': 0
} }
} }

View File

@ -394,9 +394,9 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select tabAccount.name from `tabAccount` return frappe.db.sql("""select tabAccount.name from `tabAccount`
where (tabAccount.report_type = "Profit and Loss" where (tabAccount.report_type = "Profit and Loss"
or tabAccount.account_type in ("Expense Account", "Fixed Asset")) 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.docstatus!=2
and tabAccount.company = '%(company)s' and tabAccount.company = '%(company)s'
and tabAccount.%(key)s LIKE '%(txt)s' and tabAccount.%(key)s LIKE '%(txt)s'
%(mcond)s""" % {'company': filters['company'], 'key': searchfield, %(mcond)s""" % {'company': filters['company'], 'key': searchfield,
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)}) 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})

View File

@ -291,7 +291,7 @@ cur_frm.fields_dict.debit_to.get_query = function(doc) {
return{ return{
filters: { filters: {
'report_type': 'Balance Sheet', 'report_type': 'Balance Sheet',
'group_or_ledger': 'Ledger', 'is_group': 0,
'company': doc.company 'company': doc.company
} }
} }
@ -302,7 +302,7 @@ cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
filters: [ filters: [
["Account", "account_type", "in", ["Cash", "Bank"]], ["Account", "account_type", "in", ["Cash", "Bank"]],
["Account", "root_type", "=", "Asset"], ["Account", "root_type", "=", "Asset"],
["Account", "group_or_ledger", "=", "Ledger"], ["Account", "is_group", "=",0],
["Account", "company", "=", doc.company] ["Account", "company", "=", doc.company]
] ]
} }
@ -312,7 +312,7 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) {
return{ return{
filters:{ filters:{
'report_type': 'Profit and Loss', 'report_type': 'Profit and Loss',
'group_or_ledger': 'Ledger', 'is_group': 0,
'company': doc.company '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) { cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
return{ return{
filters:{ filters:{
'group_or_ledger': 'Ledger', 'is_group': 0,
'company': doc.company 'company': doc.company
} }
} }
@ -354,7 +354,7 @@ if (sys_defaults.auto_accounting_for_stock) {
filters: { filters: {
'report_type': 'Profit and Loss', 'report_type': 'Profit and Loss',
'company': doc.company, '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 { return {
filters: { filters: {
'company': doc.company, 'company': doc.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }

View File

@ -449,7 +449,7 @@ class SalesInvoice(SellingController):
def make_gl_entries(self, repost_future_gle=True): def make_gl_entries(self, repost_future_gle=True):
gl_entries = self.get_gl_entries() gl_entries = self.get_gl_entries()
if gl_entries: if gl_entries:
from erpnext.accounts.general_ledger import make_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` return frappe.db.sql("""select tabAccount.name from `tabAccount`
where (tabAccount.report_type = "Profit and Loss" where (tabAccount.report_type = "Profit and Loss"
or tabAccount.account_type = "Income Account") or tabAccount.account_type = "Income Account")
and tabAccount.group_or_ledger="Ledger" and tabAccount.is_group=0
and tabAccount.docstatus!=2 and tabAccount.docstatus!=2
and tabAccount.company = '%(company)s' and tabAccount.company = '%(company)s'
and tabAccount.%(key)s LIKE '%(txt)s' and tabAccount.%(key)s LIKE '%(txt)s'

View File

@ -24,18 +24,16 @@ frappe.pages["Accounts Browser"].on_page_load = function(wrapper){
'<ol>'+ '<ol>'+
'<li>'+__('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'</li>'+ '<li>'+__('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'</li>'+
'<li>'+ '<li>'+
__('Accounting Entries can be made against leaf nodes, called')+ __('Accounting Entries can be made against leaf nodes. Entries against Groups are not allowed.')+
' <b>' +__('Ledgers')+'</b>. '+ __('Entries against ') +
'<b>' +__('Groups') + '</b> '+ __('are not allowed.')+
'</li>'+ '</li>'+
'<li>'+__('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+ '<li>'+__('Please do NOT create Accounts for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+
'<li>'+ '<li>'+
'<b>'+__('To create a Bank Account')+'</b>: '+ '<b>'+__('To create a Bank Account')+'</b>: '+
__('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"')+
'</li>'+ '</li>'+
'<li>'+ '<li>'+
'<b>'+__('To create a Tax Account') +'</b>: '+ '<b>'+__('To create a Tax Account') +'</b>: '+
__('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.')+
'</li>'+ '</li>'+
'</ol>'+ '</ol>'+
'<p>'+__('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main); '<p>'+__('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
@ -201,9 +199,8 @@ erpnext.AccountsChart = Class.extend({
fields: [ fields: [
{fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true, {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")}, 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'), {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
options:'Group\nLedger', "default": "Ledger", description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
description: __('Further accounts can be made under Groups, but entries can be made against Ledger')},
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'), {fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
options: ['', 'Bank', 'Cash', 'Warehouse', 'Receivable', 'Payable', options: ['', 'Bank', 'Cash', 'Warehouse', 'Receivable', 'Payable',
'Equity', 'Cost of Goods Sold', 'Fixed Asset', 'Expense Account', 'Equity', 'Cost of Goods Sold', 'Fixed Asset', 'Expense Account',
@ -217,8 +214,8 @@ erpnext.AccountsChart = Class.extend({
var fd = d.fields_dict; var fd = d.fields_dict;
// account type if ledger // account type if ledger
$(fd.group_or_ledger.input).change(function() { $(fd.is_group.input).change(function() {
if($(this).val()=='Group') { if($(this).prop("checked")) {
$(fd.account_type.wrapper).toggle(false); $(fd.account_type.wrapper).toggle(false);
$(fd.tax_rate.wrapper).toggle(false); $(fd.tax_rate.wrapper).toggle(false);
$(fd.warehouse.wrapper).toggle(false); $(fd.warehouse.wrapper).toggle(false);
@ -263,11 +260,11 @@ erpnext.AccountsChart = Class.extend({
// show // show
d.on_page_show = function() { d.on_page_show = function() {
$(fd.group_or_ledger.input).change(); $(fd.is_group.input).change();
$(fd.account_type.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(); d.show();
}, },
@ -278,8 +275,8 @@ erpnext.AccountsChart = Class.extend({
title:__('New Cost Center'), title:__('New Cost Center'),
fields: [ fields: [
{fieldtype:'Data', fieldname:'cost_center_name', label:__('New Cost Center Name'), reqd:true}, {fieldtype:'Data', fieldname:'cost_center_name', label:__('New Cost Center Name'), reqd:true},
{fieldtype:'Select', fieldname:'group_or_ledger', label:__('Group or Ledger'), {fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
options:'Group\nLedger', description:__('Further accounts can be made under Groups but entries can be made against Ledger')}, 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') } {fieldtype:'Button', fieldname:'create_new', label:__('Create New') }
] ]
}); });

View File

@ -21,7 +21,7 @@ def get_children():
# root # root
if args['parent'] in ("Accounts", "Cost Centers"): if args['parent'] in ("Accounts", "Cost Centers"):
acc = frappe.db.sql(""" select 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` from `tab%s`
where ifnull(parent_%s,'') = '' where ifnull(parent_%s,'') = ''
and `company` = %s and docstatus<2 and `company` = %s and docstatus<2
@ -30,7 +30,7 @@ def get_children():
else: else:
# other # other
acc = frappe.db.sql("""select 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` from `tab%s`
where ifnull(parent_%s,'') = %s where ifnull(parent_%s,'') = %s
and docstatus<2 and docstatus<2

View File

@ -265,7 +265,7 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
var me= this; var me= this;
$.each(this.data, function(i, account) { $.each(this.data, function(i, account) {
// update groups // 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]; var parent = me.parent_map[account.name];
while(parent) { while(parent) {
var parent_account = me.item_by_name[parent]; var parent_account = me.item_by_name[parent];

View File

@ -188,17 +188,6 @@ class ReceivablePayableReport(object):
conditions.append("party_type=%s and party=%s") conditions.append("party_type=%s and party=%s")
values += [party_type, self.filters.get(party_type_field)] 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 return " and ".join(conditions), values
def get_gl_entries_for(self, party, party_type, against_voucher_type, against_voucher): def get_gl_entries_for(self, party, party_type, against_voucher_type, against_voucher):

View File

@ -24,13 +24,13 @@ frappe.query_reports["Bank Clearance Summary"] = {
"reqd": 1, "reqd": 1,
"get_query": function() { "get_query": function() {
return { return {
"query": "erpnext.controllers.queries.get_account_list", "query": "erpnext.controllers.queries.get_account_list",
"filters": [ "filters": [
['Account', 'account_type', 'in', 'Bank, Cash'], ['Account', 'account_type', 'in', 'Bank, Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'is_group', '=', 0],
] ]
} }
} }
}, },
] ]
} }

View File

@ -14,7 +14,7 @@ frappe.query_reports["Bank Reconciliation Statement"] = {
"query": "erpnext.controllers.queries.get_account_list", "query": "erpnext.controllers.queries.get_account_list",
"filters": [ "filters": [
['Account', 'account_type', 'in', 'Bank, Cash'], ['Account', 'account_type', 'in', 'Bank, Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'is_group', '=', 0],
] ]
} }
} }

View File

@ -8,7 +8,7 @@ from frappe import _
def execute(filters=None): def execute(filters=None):
account_details = {} 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) account_details.setdefault(acc.name, acc)
validate_filters(filters, account_details) 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)) frappe.throw(_("Account {0} does not exists").format(filters.account))
if filters.get("account") and filters.get("group_by_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")) frappe.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by_voucher"): 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)) frappe.throw(_("Invalid {0}: {1}").format(party_type, party))
def get_columns(): def get_columns():
return [_("Posting Date") + ":Date:90", _("Account") + ":Link/Account:200", return [_("Posting Date") + ":Date:90", _("Account") + ":Link/Account:200",
_("Debit") + ":Float:100", _("Credit") + ":Float:100", _("Debit") + ":Float:100", _("Credit") + ":Float:100",
_("Voucher Type") + "::120", _("Voucher No") + ":Dynamic Link/Voucher Type:160", _("Voucher Type") + "::120", _("Voucher No") + ":Dynamic Link/Voucher Type:160",
_("Against Account") + "::120", _("Party Type") + "::80", _("Party") + "::150", _("Against Account") + "::120", _("Party Type") + "::80", _("Party") + "::150",
_("Cost Center") + ":Link/Cost Center:100", _("Remarks") + "::400"] _("Cost Center") + ":Link/Cost Center:100", _("Remarks") + "::400"]
def get_result(filters, account_details): def get_result(filters, account_details):
@ -179,7 +179,7 @@ def get_result_as_list(data):
for d in data: for d in data:
result.append([d.get("posting_date"), d.get("account"), d.get("debit"), 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("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")]) d.get("cost_center"), d.get("remarks")])
return result return result

View File

@ -89,7 +89,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None):
% year_start_date) % year_start_date)
# different filter for group and ledger - improved performance # different filter for group and ledger - improved performance
if acc.group_or_ledger=="Group": if acc.is_group:
cond.append("""exists ( cond.append("""exists (
select * from `tabAccount` ac where ac.name = gle.account select * from `tabAccount` ac where ac.name = gle.account
and ac.lft >= %s and ac.rgt <= %s and ac.lft >= %s and ac.rgt <= %s

View File

@ -65,7 +65,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d
filters: { filters: {
'account_type': 'Payable', 'account_type': 'Payable',
'company': d.company, 'company': d.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }

View File

@ -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 tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2 where tabAccount.docstatus!=2
and account_type in (%s) and account_type in (%s)
and group_or_ledger = 'Ledger' and is_group = 0
and company = %s and company = %s
and `%s` LIKE %s and `%s` LIKE %s
limit %s, %s""" % limit %s, %s""" %
@ -147,7 +147,7 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
start, page_len])) start, page_len]))
if not tax_accounts: if not tax_accounts:
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount 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""" and company = %s and `%s` LIKE %s limit %s, %s"""
% ("%s", searchfield, "%s", "%s", "%s"), % ("%s", searchfield, "%s", "%s", "%s"),
(filters.get("company"), "%%%s%%" % txt, start, page_len)) (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): elif isinstance(filters, list):
filter_list.extend(filters) filter_list.extend(filters)
if "group_or_ledger" not in [d[1] for d in filter_list]: if "is_group" not in [d[1] for d in filter_list]:
filter_list.append(["Account", "group_or_ledger", "=", "Ledger"]) filter_list.append(["Account", "is_group", "=", "0"])
if searchfield and txt: if searchfield and txt:
filter_list.append([doctype, searchfield, "like", "%%%s%%" % txt]) filter_list.append([doctype, searchfield, "like", "%%%s%%" % txt])

View File

@ -5,12 +5,12 @@
"doctype": "Report", "doctype": "Report",
"idx": 1, "idx": 1,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2015-03-30 05:43:59.976254", "modified": "2015-04-23 03:26:35.711681",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Open Production Orders", "name": "Open Production Orders",
"owner": "Administrator", "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", "ref_doctype": "Production Order",
"report_name": "Open Production Orders", "report_name": "Open Production Orders",
"report_type": "Query Report" "report_type": "Query Report"

View File

@ -101,6 +101,7 @@ execute:frappe.reload_doc('crm', 'doctype', 'lead')
execute:frappe.reload_doc('crm', 'doctype', 'opportunity') execute:frappe.reload_doc('crm', 'doctype', 'opportunity')
erpnext.patches.v5_0.rename_table_fieldnames erpnext.patches.v5_0.rename_table_fieldnames
execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''") 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.v4_2.party_model
erpnext.patches.v5_0.party_model_patch_fix erpnext.patches.v5_0.party_model_patch_fix
erpnext.patches.v4_1.fix_jv_remarks erpnext.patches.v4_1.fix_jv_remarks

View File

@ -25,7 +25,7 @@ def create_receivable_payable_account():
def _create_account(args): def _create_account(args):
account = frappe.new_doc("Account") account = frappe.new_doc("Account")
account.group_or_ledger = "Ledger" account.is_group = 0
account.update(args) account.update(args)
account.insert() 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), 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)) (new_account, account_details.get("master_type"), account_details.get("master_name"), d.name))
if i%500 == 0: if i%500 == 0:
frappe.db.commit() frappe.db.commit()

View File

@ -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)")

View File

@ -178,7 +178,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
var me= this; var me= this;
$.each(this.data, function(i, account) { $.each(this.data, function(i, account) {
// update groups // 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]; var parent = me.parent_map[account.name];
while(parent) { while(parent) {
var parent_account = me.item_by_name[parent]; var parent_account = me.item_by_name[parent];

View File

@ -162,7 +162,7 @@ frappe.ui.form.on(cur_frm.doctype, "onload", function(frm) {
return { return {
filters: { filters: {
'company': doc.company, 'company': doc.company,
'group_or_ledger': "Ledger" "is_group": 0
} }
} }
}); });

View File

@ -93,7 +93,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d
filters: { filters: {
'account_type': 'Receivable', 'account_type': 'Receivable',
'company': d.company, 'company': d.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }

View File

@ -114,7 +114,7 @@ cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
return{ return{
filters: [ filters: [
['Account', 'account_type', '=', 'Bank'], ['Account', 'account_type', '=', 'Bank'],
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'is_group', '=', 0],
['Account', 'company', '=', doc.name] ['Account', 'company', '=', doc.name]
] ]
} }
@ -124,7 +124,7 @@ cur_frm.fields_dict.default_cash_account.get_query = function(doc) {
return{ return{
filters: [ filters: [
['Account', 'account_type', '=', 'Cash'], ['Account', 'account_type', '=', 'Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'], ['Account', 'is_group', '=', 0],
['Account', 'company', '=', doc.name] ['Account', 'company', '=', doc.name]
] ]
} }
@ -134,7 +134,7 @@ cur_frm.fields_dict.default_receivable_account.get_query = function(doc) {
return{ return{
filters:{ filters:{
'company': doc.name, 'company': doc.name,
'group_or_ledger': "Ledger", "is_group": 0,
"account_type": "Receivable" "account_type": "Receivable"
} }
} }
@ -144,7 +144,7 @@ cur_frm.fields_dict.default_payable_account.get_query = function(doc) {
return{ return{
filters:{ filters:{
'company': doc.name, 'company': doc.name,
'group_or_ledger': "Ledger", "is_group": 0,
"account_type": "Payable" "account_type": "Payable"
} }
} }
@ -156,7 +156,7 @@ cur_frm.fields_dict.default_expense_account.get_query = function(doc) {
return{ return{
filters:{ filters:{
'company': doc.name, 'company': doc.name,
'group_or_ledger': "Ledger", "is_group": 0,
"report_type": "Profit and Loss" "report_type": "Profit and Loss"
} }
} }
@ -166,7 +166,7 @@ cur_frm.fields_dict.default_income_account.get_query = function(doc) {
return{ return{
filters:{ filters:{
'company': doc.name, 'company': doc.name,
'group_or_ledger': "Ledger", "is_group": 0,
"report_type": "Profit and Loss" "report_type": "Profit and Loss"
} }
} }
@ -176,7 +176,7 @@ cur_frm.fields_dict.cost_center.get_query = function(doc) {
return{ return{
filters:{ filters:{
'company': doc.name, 'company': doc.name,
'group_or_ledger': "Ledger", "is_group": 0,
} }
} }
} }
@ -187,7 +187,7 @@ if (sys_defaults.auto_accounting_for_stock) {
"filters": { "filters": {
"report_type": "Profit and Loss", "report_type": "Profit and Loss",
"company": doc.name, "company": doc.name,
'group_or_ledger': "Ledger" "is_group": 0
} }
} }
} }
@ -200,7 +200,7 @@ if (sys_defaults.auto_accounting_for_stock) {
"filters": { "filters": {
"report_type": "Balance Sheet", "report_type": "Balance Sheet",
"company": doc.name, "company": doc.name,
'group_or_ledger': "Ledger" "is_group": 0
} }
} }
} }

View File

@ -55,7 +55,7 @@ class Company(Document):
self.create_default_warehouses() self.create_default_warehouses()
self.install_country_fixtures() 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.create_default_cost_center()
self.set_default_accounts() self.set_default_accounts()
@ -71,7 +71,7 @@ class Company(Document):
for whname in (_("Stores"), _("Work In Progress"), _("Finished Goods")): for whname in (_("Stores"), _("Work In Progress"), _("Finished Goods")):
if not frappe.db.exists("Warehouse", whname + " - " + self.abbr): if not frappe.db.exists("Warehouse", whname + " - " + self.abbr):
stock_group = frappe.db.get_value("Account", {"account_type": "Stock", 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: if stock_group:
frappe.get_doc({ frappe.get_doc({
"doctype":"Warehouse", "doctype":"Warehouse",
@ -125,7 +125,7 @@ class Company(Document):
return return
account = frappe.db.get_value("Account", {"account_type": account_type, 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: if account:
self.db_set(fieldname, account) self.db_set(fieldname, account)
@ -135,13 +135,13 @@ class Company(Document):
{ {
'cost_center_name': self.name, 'cost_center_name': self.name,
'company':self.name, 'company':self.name,
'group_or_ledger':'Group', 'is_group': 1,
'parent_cost_center':None 'parent_cost_center':None
}, },
{ {
'cost_center_name':_('Main'), 'cost_center_name':_('Main'),
'company':self.name, 'company':self.name,
'group_or_ledger':'Ledger', 'is_group':0,
'parent_cost_center':self.name + ' - ' + self.abbr 'parent_cost_center':self.name + ' - ' + self.abbr
}, },
] ]

View File

@ -32,7 +32,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d
filters: { filters: {
'account_type': 'Receivable', 'account_type': 'Receivable',
'company': d.company, 'company': d.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }

View File

@ -394,7 +394,7 @@ class EmailDigest(Document):
if not hasattr(self, "accounts"): if not hasattr(self, "accounts"):
self.accounts = frappe.db.sql("""select name, account_type, account_name, root_type self.accounts = frappe.db.sql("""select name, account_type, account_name, root_type
from `tabAccount` where company=%s and docstatus < 2 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) (self.company,), as_dict=1)
return self.accounts return self.accounts

View File

@ -11,7 +11,7 @@ cur_frm.fields_dict['accounts'].grid.get_field('account').get_query = function(d
filters: { filters: {
'account_type': 'Payable', 'account_type': 'Payable',
'company': d.company, 'company': d.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }

View File

@ -297,14 +297,14 @@ def create_taxes(args):
try: try:
tax_group = frappe.db.get_value("Account", {"company": args.get("company_name"), 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: if tax_group:
frappe.get_doc({ frappe.get_doc({
"doctype":"Account", "doctype":"Account",
"company": args.get("company_name").strip(), "company": args.get("company_name").strip(),
"parent_account": tax_group, "parent_account": tax_group,
"account_name": args.get("tax_" + str(i)), "account_name": args.get("tax_" + str(i)),
"group_or_ledger": "Ledger", "is_group": 0,
"report_type": "Balance Sheet", "report_type": "Balance Sheet",
"account_type": "Tax", "account_type": "Tax",
"tax_rate": flt(tax_rate) if tax_rate else None "tax_rate": flt(tax_rate) if tax_rate else None
@ -330,69 +330,78 @@ def create_items(args):
"company": args.get("company_name").strip() "company": args.get("company_name").strip()
}) })
frappe.get_doc({ try:
"doctype":"Item", frappe.get_doc({
"item_code": item, "doctype":"Item",
"item_name": item, "item_code": item,
"description": item, "item_name": item,
"is_sales_item": "Yes" if is_sales_item else "No", "description": item,
"is_purchase_item": "Yes" if is_purchase_item else "No", "is_sales_item": "Yes" if is_sales_item else "No",
"show_in_website": 1, "is_purchase_item": "Yes" if is_purchase_item else "No",
"is_stock_item": is_stock_item and "Yes" or "No", "show_in_website": 1,
"item_group": item_group, "is_stock_item": is_stock_item and "Yes" or "No",
"stock_uom": args.get("item_uom_" + str(i)), "item_group": item_group,
"default_warehouse": default_warehouse "stock_uom": args.get("item_uom_" + str(i)),
}).insert() "default_warehouse": default_warehouse
}).insert()
if args.get("item_img_" + str(i)): if args.get("item_img_" + str(i)):
item_image = args.get("item_img_" + str(i)).split(",") item_image = args.get("item_img_" + str(i)).split(",")
if len(item_image)==3: if len(item_image)==3:
filename, filetype, content = item_image filename, filetype, content = item_image
fileurl = save_file(filename, content, "Item", item, decode=True).file_url fileurl = save_file(filename, content, "Item", item, decode=True).file_url
frappe.db.set_value("Item", item, "image", fileurl) frappe.db.set_value("Item", item, "image", fileurl)
except frappe.NameError:
pass
def create_customers(args): def create_customers(args):
for i in xrange(1,6): for i in xrange(1,6):
customer = args.get("customer_" + str(i)) customer = args.get("customer_" + str(i))
if customer: if customer:
frappe.get_doc({ try:
"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({ frappe.get_doc({
"doctype":"Contact", "doctype":"Customer",
"customer": customer, "customer_name": customer,
"first_name":contact[0], "customer_type": "Company",
"last_name": len(contact) > 1 and contact[1] or "" "customer_group": _("Commercial"),
"territory": args.get("country"),
"company": args.get("company_name").strip()
}).insert() }).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): def create_suppliers(args):
for i in xrange(1,6): for i in xrange(1,6):
supplier = args.get("supplier_" + str(i)) supplier = args.get("supplier_" + str(i))
if supplier: if supplier:
frappe.get_doc({ try:
"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({ frappe.get_doc({
"doctype":"Contact", "doctype":"Supplier",
"supplier": supplier, "supplier_name": supplier,
"first_name":contact[0], "supplier_type": _("Local"),
"last_name": len(contact) > 1 and contact[1] or "" "company": args.get("company_name").strip()
}).insert() }).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): def create_letter_head(args):
if args.get("attach_letterhead"): if args.get("attach_letterhead"):

View File

@ -19,7 +19,7 @@ data_map = {
# Accounts # Accounts
"Account": { "Account": {
"columns": ["name", "parent_account", "lft", "rgt", "report_type", "columns": ["name", "parent_account", "lft", "rgt", "report_type",
"company", "group_or_ledger"], "company", "is_group"],
"conditions": ["docstatus < 2"], "conditions": ["docstatus < 2"],
"order_by": "lft", "order_by": "lft",
"links": { "links": {

View File

@ -214,7 +214,7 @@ if (sys_defaults.auto_accounting_for_stock) {
filters: { filters: {
"report_type": "Profit and Loss", "report_type": "Profit and Loss",
"company": doc.company, "company": doc.company,
"group_or_ledger": "Ledger" "is_group": 0
} }
} }
} }
@ -236,7 +236,7 @@ if (sys_defaults.auto_accounting_for_stock) {
filters: { filters: {
'company': doc.company, 'company': doc.company,
'group_or_ledger': "Ledger" "is_group": 0
} }
} }
} }

View File

@ -122,7 +122,7 @@ $.extend(erpnext.item, {
return { return {
filters: { filters: {
"report_type": "Profit and Loss", "report_type": "Profit and Loss",
"group_or_ledger": "Ledger" "is_group": 0
} }
} }
} }
@ -133,7 +133,7 @@ $.extend(erpnext.item, {
return { return {
filters: { filters: {
"report_type": "Profit and Loss", "report_type": "Profit and Loss",
'group_or_ledger': "Ledger", "is_group": 0,
'account_type': "Income Account" 'account_type': "Income Account"
} }
} }
@ -144,7 +144,7 @@ $.extend(erpnext.item, {
// ----------------------------- // -----------------------------
frm.fields_dict['buying_cost_center'].get_query = function(doc) { frm.fields_dict['buying_cost_center'].get_query = function(doc) {
return { 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) { frm.fields_dict['selling_cost_center'].get_query = function(doc) {
return { return {
filters:{ 'group_or_ledger': "Ledger" } filters:{ "is_group": 0 }
} }
} }

View File

@ -51,7 +51,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
return { return {
filters: { filters: {
"company": me.frm.doc.company, "company": me.frm.doc.company,
"group_or_ledger": "Ledger" "is_group": 0
} }
} }
} }

View File

@ -65,7 +65,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
return { return {
"filters": { "filters": {
'company': me.frm.doc.company, 'company': me.frm.doc.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }
@ -73,7 +73,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
return { return {
"filters": { "filters": {
'company': me.frm.doc.company, 'company': me.frm.doc.company,
'group_or_ledger': 'Ledger' "is_group": 0
} }
} }
} }

View File

@ -9,7 +9,7 @@ cur_frm.set_query("create_account_under", function() {
return { return {
filters: { filters: {
"company": cur_frm.doc.company, "company": cur_frm.doc.company,
'group_or_ledger': "Group" 'is_group': 1
} }
} }
}) })

View File

@ -48,7 +48,7 @@ class Warehouse(Document):
"doctype": "Account", "doctype": "Account",
'account_name': self.warehouse_name, 'account_name': self.warehouse_name,
'parent_account': self.create_account_under, 'parent_account': self.create_account_under,
'group_or_ledger':'Ledger', 'is_group':0,
'company':self.company, 'company':self.company,
"account_type": "Warehouse", "account_type": "Warehouse",
"warehouse": self.name, "warehouse": self.name,