From caba531e89ef2019c93207b9a6e56f9960177ac2 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 20 Aug 2014 17:20:29 +0530 Subject: [PATCH] [fix] issue#980 --- .../setup/doctype/item_group/item_group.json | 33 +++++++++++++++++-- erpnext/stock/get_item_details.py | 20 +++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/erpnext/setup/doctype/item_group/item_group.json b/erpnext/setup/doctype/item_group/item_group.json index fff066cef7..1a18710133 100644 --- a/erpnext/setup/doctype/item_group/item_group.json +++ b/erpnext/setup/doctype/item_group/item_group.json @@ -22,9 +22,10 @@ "search_index": 0 }, { - "fieldname": "cb0", - "fieldtype": "Column Break", + "fieldname": "gs", + "fieldtype": "Section Break", "in_list_view": 0, + "label": "General Settings", "permlevel": 0 }, { @@ -56,6 +57,32 @@ "reqd": 1, "search_index": 0 }, + { + "fieldname": "column_break_5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "default_income_account", + "fieldtype": "Link", + "label": "Default Income Account", + "options": "Account", + "permlevel": 0 + }, + { + "fieldname": "default_expense_account", + "fieldtype": "Link", + "label": "Default Expense Account", + "options": "Account", + "permlevel": 0 + }, + { + "fieldname": "default_cost_center", + "fieldtype": "Link", + "label": "Default Cost Center", + "options": "Cost Center", + "permlevel": 0 + }, { "fieldname": "sb9", "fieldtype": "Section Break", @@ -164,7 +191,7 @@ "in_create": 1, "issingle": 0, "max_attachments": 3, - "modified": "2014-08-19 06:42:03.262273", + "modified": "2014-08-20 17:48:34.489750", "modified_by": "Administrator", "module": "Setup", "name": "Item Group", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 82b396fb39..efb793deea 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -35,6 +35,7 @@ def get_item_details(args): item_doc = frappe.get_doc("Item", args.item_code) item = item_doc + validate_item_details(args, item) out = get_basic_details(args, item_doc) @@ -135,16 +136,22 @@ def get_basic_details(args, item_doc): if len(user_default_warehouse_list)==1 else "" out = frappe._dict({ + "item_code": item.name, "item_name": item.item_name, "description": item.description_html or item.description, "warehouse": user_default_warehouse or args.warehouse or item.default_warehouse, - "income_account": item.income_account or args.income_account \ - or frappe.db.get_value("Company", args.company, "default_income_account"), - "expense_account": item.expense_account or args.expense_account \ - or frappe.db.get_value("Company", args.company, "default_expense_account"), - "cost_center": item.selling_cost_center \ - if args.transaction_type == "selling" else item.buying_cost_center, + "income_account": (item.income_account + or args.income_account + or frappe.db.get_value("Item Group", item.item_group, "default_income_account") + or frappe.db.get_value("Company", args.company, "default_income_account")), + "expense_account": (item.expense_account + or args.expense_account + or frappe.db.get_value("Item Group", item.item_group, "default_expense_account") + or frappe.db.get_value("Company", args.company, "default_expense_account")), + "cost_center": ((item.selling_cost_center if args.transaction_type == "selling" else item.buying_cost_center) + or frappe.db.get_value("Item Group", item.item_group, "default_cost_center") + or frappe.db.get_value("Company", args.company, "cost_center")), "batch_no": None, "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in item_doc.get("item_tax")))), @@ -174,6 +181,7 @@ def get_price_list_rate(args, item_doc, out): validate_price_list(args) validate_conversion_rate(args, meta) + price_list_rate = frappe.db.get_value("Item Price", {"price_list": args.price_list, "item_code": args.item_code}, "price_list_rate")