[fixes] rename ctype to doctype
This commit is contained in:
parent
001d4d74fa
commit
dc2fa86222
@ -448,13 +448,13 @@ def get_companies():
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children():
|
def get_children():
|
||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
ctype, company = args['ctype'], args['company']
|
doctype, company = args['doctype'], args['company']
|
||||||
fieldname = frappe.db.escape(ctype.lower().replace(' ','_'))
|
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
|
||||||
doctype = frappe.db.escape(ctype)
|
doctype = frappe.db.escape(doctype)
|
||||||
|
|
||||||
# root
|
# root
|
||||||
if args['parent'] in ("Accounts", "Cost Centers"):
|
if args['parent'] in ("Accounts", "Cost Centers"):
|
||||||
fields = ", root_type, report_type, account_currency" if ctype=="Account" else ""
|
fields = ", root_type, report_type, account_currency" if doctype=="Account" else ""
|
||||||
acc = frappe.db.sql(""" select
|
acc = frappe.db.sql(""" select
|
||||||
name as value, is_group as expandable {fields}
|
name as value, is_group as expandable {fields}
|
||||||
from `tab{doctype}`
|
from `tab{doctype}`
|
||||||
@ -467,7 +467,7 @@ def get_children():
|
|||||||
sort_root_accounts(acc)
|
sort_root_accounts(acc)
|
||||||
else:
|
else:
|
||||||
# other
|
# other
|
||||||
fields = ", account_currency" if ctype=="Account" else ""
|
fields = ", account_currency" if doctype=="Account" else ""
|
||||||
acc = frappe.db.sql("""select
|
acc = frappe.db.sql("""select
|
||||||
name as value, is_group as expandable, parent_{fieldname} as parent {fields}
|
name as value, is_group as expandable, parent_{fieldname} as parent {fields}
|
||||||
from `tab{doctype}`
|
from `tab{doctype}`
|
||||||
@ -476,7 +476,7 @@ def get_children():
|
|||||||
order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
|
order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
|
||||||
args['parent'], as_dict=1)
|
args['parent'], as_dict=1)
|
||||||
|
|
||||||
if ctype == 'Account':
|
if doctype == 'Account':
|
||||||
company_currency = frappe.db.get_value("Company", company, "default_currency")
|
company_currency = frappe.db.get_value("Company", company, "default_currency")
|
||||||
for each in acc:
|
for each in acc:
|
||||||
each["company_currency"] = company_currency
|
each["company_currency"] = company_currency
|
||||||
|
@ -12,7 +12,6 @@ def execute():
|
|||||||
"parent_warehouse", "is_group"]):
|
"parent_warehouse", "is_group"]):
|
||||||
set_parent_to_warehouses(warehouse, company)
|
set_parent_to_warehouses(warehouse, company)
|
||||||
set_parent_to_warehouse_acounts(warehouse, company)
|
set_parent_to_warehouse_acounts(warehouse, company)
|
||||||
frappe.db.commit()
|
|
||||||
|
|
||||||
def set_parent_to_warehouses(warehouse, company):
|
def set_parent_to_warehouses(warehouse, company):
|
||||||
warehouse = frappe.get_doc("Warehouse", warehouse.name)
|
warehouse = frappe.get_doc("Warehouse", warehouse.name)
|
||||||
@ -31,10 +30,6 @@ def set_parent_to_warehouse_acounts(warehouse, company):
|
|||||||
if account and account != "{0} - {1}".format(_("All Warehouses"), company.abbr):
|
if account and account != "{0} - {1}".format(_("All Warehouses"), company.abbr):
|
||||||
account = frappe.get_doc("Account", account)
|
account = frappe.get_doc("Account", account)
|
||||||
|
|
||||||
if warehouse.is_group == "Yes":
|
|
||||||
account.is_group = 1
|
|
||||||
account.account_type = ""
|
|
||||||
|
|
||||||
if warehouse.create_account_under == stock_group or not warehouse.create_account_under:
|
if warehouse.create_account_under == stock_group or not warehouse.create_account_under:
|
||||||
if not warehouse.parent_warehouse:
|
if not warehouse.parent_warehouse:
|
||||||
account.parent_account = "{0} - {1}".format(_("All Warehouses"), company.abbr)
|
account.parent_account = "{0} - {1}".format(_("All Warehouses"), company.abbr)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
cur_frm.list_route = "Tree/Warehouse";
|
||||||
|
|
||||||
frappe.ui.form.on("Warehouse", {
|
frappe.ui.form.on("Warehouse", {
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
frm.toggle_display('warehouse_name', frm.doc.__islocal);
|
frm.toggle_display('warehouse_name', frm.doc.__islocal);
|
||||||
|
@ -176,10 +176,10 @@ class Warehouse(NestedSet):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children():
|
def get_children():
|
||||||
from erpnext.stock.utils import get_stock_value_on
|
from erpnext.stock.utils import get_stock_value_on
|
||||||
ctype = frappe.local.form_dict.get('ctype')
|
doctype = frappe.local.form_dict.get('doctype')
|
||||||
company = frappe.local.form_dict.get('company')
|
company = frappe.local.form_dict.get('company')
|
||||||
|
|
||||||
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
parent_field = 'parent_' + doctype.lower().replace(' ', '_')
|
||||||
parent = frappe.form_dict.get("parent") or ""
|
parent = frappe.form_dict.get("parent") or ""
|
||||||
|
|
||||||
if parent == "Warehouses":
|
if parent == "Warehouses":
|
||||||
@ -187,10 +187,10 @@ def get_children():
|
|||||||
|
|
||||||
warehouses = frappe.db.sql("""select name as value,
|
warehouses = frappe.db.sql("""select name as value,
|
||||||
if(is_group='Yes', 1, 0) as expandable
|
if(is_group='Yes', 1, 0) as expandable
|
||||||
from `tab{ctype}`
|
from `tab{doctype}`
|
||||||
where docstatus < 2
|
where docstatus < 2
|
||||||
and ifnull(`{parent_field}`,'') = %s and `company` = %s
|
and ifnull(`{parent_field}`,'') = %s and `company` = %s
|
||||||
order by name""".format(ctype=frappe.db.escape(ctype), parent_field=frappe.db.escape(parent_field)),
|
order by name""".format(doctype=frappe.db.escape(doctype), parent_field=frappe.db.escape(parent_field)),
|
||||||
(parent, company), as_dict=1)
|
(parent, company), as_dict=1)
|
||||||
|
|
||||||
# return warehouses
|
# return warehouses
|
||||||
@ -200,12 +200,12 @@ def get_children():
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_node():
|
def add_node():
|
||||||
ctype = frappe.form_dict.get('ctype')
|
doctype = frappe.form_dict.get('doctype')
|
||||||
company = frappe.form_dict.get('company')
|
company = frappe.form_dict.get('company')
|
||||||
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
parent_field = 'parent_' + doctype.lower().replace(' ', '_')
|
||||||
name_field = ctype.lower().replace(' ', '_') + '_name'
|
name_field = doctype.lower().replace(' ', '_') + '_name'
|
||||||
|
|
||||||
doc = frappe.new_doc(ctype)
|
doc = frappe.new_doc(doctype)
|
||||||
|
|
||||||
parent = frappe.form_dict['parent']
|
parent = frappe.form_dict['parent']
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user