[Fix] Patch, default cost center, expense account for the item

This commit is contained in:
Rohit Waghchaure 2018-05-21 16:43:50 +05:30
parent 7d6cad2c67
commit 0ca7ba3247
2 changed files with 7 additions and 4 deletions

View File

@ -264,9 +264,12 @@ def get_accumulated_monthly_budget(monthly_distribution, posting_date, fiscal_ye
def get_item_details(args): def get_item_details(args):
cost_center, expense_account = None, None cost_center, expense_account = None, None
if not args.get('company'):
return cost_center, expense_account
if args.item_code: if args.item_code:
cost_center, expense_account = frappe.db.get_value('Item', cost_center, expense_account = frappe.db.get_value('Item Default',
args.item_code, ['buying_cost_center', 'expense_account']) {'parent': args.item_code, 'company': args.get('company')}, ['buying_cost_center', 'expense_account'])
if not (cost_center and expense_account): if not (cost_center and expense_account):
for doctype in ['Item Group', 'Company']: for doctype in ['Item Group', 'Company']:
@ -286,6 +289,6 @@ def get_item_details(args):
def get_expense_cost_center(doctype, value): def get_expense_cost_center(doctype, value):
fields = (['default_cost_center', 'default_expense_account'] 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) return frappe.db.get_value(doctype, value, fields)

View File

@ -10,7 +10,7 @@ def execute():
frappe.reload_doc('stock', 'doctype', 'warehouse') frappe.reload_doc('stock', 'doctype', 'warehouse')
for d in frappe.get_all('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: try:
loc = frappe.new_doc('Location') loc = frappe.new_doc('Location')
loc.location_name = d.warehouse_name loc.location_name = d.warehouse_name