Merge pull request #14166 from rohitwaghchaure/version_11_patch_budget
[Fix] Patch, default cost center, expense account for the item
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index d3a0d1d..ab9b93b 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -264,9 +264,12 @@
def get_item_details(args):
cost_center, expense_account = None, None
+ if not args.get('company'):
+ return cost_center, expense_account
+
if args.item_code:
- cost_center, expense_account = frappe.db.get_value('Item',
- args.item_code, ['buying_cost_center', 'expense_account'])
+ cost_center, expense_account = frappe.db.get_value('Item Default',
+ {'parent': args.item_code, 'company': args.get('company')}, ['buying_cost_center', 'expense_account'])
if not (cost_center and expense_account):
for doctype in ['Item Group', 'Company']:
@@ -286,6 +289,6 @@
def get_expense_cost_center(doctype, value):
fields = (['default_cost_center', 'default_expense_account']
- if doctype == 'Item Group'else ['cost_center', 'default_expense_account'])
+ if doctype == 'Item Group' else ['cost_center', 'default_expense_account'])
return frappe.db.get_value(doctype, value, fields)
diff --git a/erpnext/patches/v11_0/make_location_from_warehouse.py b/erpnext/patches/v11_0/make_location_from_warehouse.py
index b838ec9..b5b2e17 100644
--- a/erpnext/patches/v11_0/make_location_from_warehouse.py
+++ b/erpnext/patches/v11_0/make_location_from_warehouse.py
@@ -10,7 +10,7 @@
frappe.reload_doc('stock', 'doctype', 'warehouse')
for d in frappe.get_all('Warehouse',
- fields = ['warehouse_name', 'is_group', 'parent_warehouse'], order_by="is_group desc"):
+ fields = ['warehouse_name', 'is_group', 'parent_warehouse'], order_by="lft asc"):
try:
loc = frappe.new_doc('Location')
loc.location_name = d.warehouse_name