[fix] deprecate browser pages for accounts, cost_center, sales , bom, item group

This commit is contained in:
Saurabh
2016-06-21 12:33:12 +05:30
parent 9c7b0079c5
commit a9ba7343c4
19 changed files with 64 additions and 787 deletions

View File

@@ -9,7 +9,8 @@ from frappe import throw, _
from frappe.utils import formatdate
# imported to enable erpnext.accounts.utils.get_account_currency
from erpnext.accounts.doctype.account.account import get_account_currency
import frappe.defaults
from erpnext.accounts.report.financial_statements import sort_root_accounts
class FiscalYearError(frappe.ValidationError): pass
@@ -436,3 +437,51 @@ def get_account_name(account_type=None, root_type=None, is_group=None, account_c
"account_currency": account_currency or frappe.defaults.get_defaults().currency,
"company": company or frappe.defaults.get_defaults().company
}, "name")
@frappe.whitelist()
def get_companies():
"""get a list of companies based on permission"""
return [d.name for d in frappe.get_list("Company", fields=["name"],
order_by="name")]
@frappe.whitelist()
def get_children():
args = frappe.local.form_dict
ctype, company = args['ctype'], args['comp']
fieldname = frappe.db.escape(ctype.lower().replace(' ','_'))
doctype = frappe.db.escape(ctype)
# root
if args['parent'] in ("Accounts", "Cost Centers"):
fields = ", root_type, report_type, account_currency" if ctype=="Account" else ""
acc = frappe.db.sql(""" select
name as value, is_group as expandable {fields}
from `tab{doctype}`
where ifnull(`parent_{fieldname}`,'') = ''
and `company` = %s and docstatus<2
order by name""".format(fields=fields, fieldname = fieldname, doctype=doctype),
company, as_dict=1)
if args["parent"]=="Accounts":
sort_root_accounts(acc)
else:
# other
fields = ", account_currency" if ctype=="Account" else ""
acc = frappe.db.sql("""select
name as value, is_group as expandable, parent_{fieldname} as parent {fields}
from `tab{doctype}`
where ifnull(`parent_{fieldname}`,'') = %s
and docstatus<2
order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
args['parent'], as_dict=1)
if ctype == 'Account':
company_currency = frappe.db.get_value("Company", company, "default_currency")
for each in acc:
each["company_currency"] = company_currency
each["balance"] = flt(get_balance_on(each.get("value"), in_account_currency=False))
if each.account_currency != company_currency:
each["balance_in_account_currency"] = flt(get_balance_on(each.get("value")))
return acc