From 0ca7ba32472119b9143d66276ea59a104f5fde75 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 21 May 2018 16:43:50 +0530 Subject: [PATCH] [Fix] Patch, default cost center, expense account for the item --- erpnext/accounts/doctype/budget/budget.py | 9 ++++++--- erpnext/patches/v11_0/make_location_from_warehouse.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index d3a0d1d754..ab9b93bb47 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -264,9 +264,12 @@ def get_accumulated_monthly_budget(monthly_distribution, posting_date, fiscal_ye 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_item_details(args): 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 b838ec98bc..b5b2e17c3b 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 @@ def execute(): 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