Merge pull request #2089 from neilLasrado/item_group

Item group
This commit is contained in:
Anand Doshi 2014-08-26 12:56:54 +05:30
commit 5ed2c06eb5
6 changed files with 54 additions and 12 deletions

View File

@ -15,5 +15,12 @@
"doctype": "Cost Center", "doctype": "Cost Center",
"group_or_ledger": "Ledger", "group_or_ledger": "Ledger",
"parent_cost_center": "_Test Company - _TC" "parent_cost_center": "_Test Company - _TC"
},
{
"company": "_Test Company",
"cost_center_name": "_Test Cost Center 2",
"doctype": "Cost Center",
"group_or_ledger": "Ledger",
"parent_cost_center": "_Test Company - _TC"
} }
] ]

View File

@ -21,9 +21,10 @@
"search_index": 0 "search_index": 0
}, },
{ {
"fieldname": "cb0", "fieldname": "gs",
"fieldtype": "Column Break", "fieldtype": "Section Break",
"in_list_view": 0, "in_list_view": 0,
"label": "General Settings",
"permlevel": 0 "permlevel": 0
}, },
{ {
@ -55,6 +56,32 @@
"reqd": 1, "reqd": 1,
"search_index": 0 "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", "fieldname": "sb9",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -163,7 +190,7 @@
"in_create": 1, "in_create": 1,
"issingle": 0, "issingle": 0,
"max_attachments": 3, "max_attachments": 3,
"modified": "2014-08-19 06:42:03.262273", "modified": "2014-08-20 17:48:34.489750",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Item Group", "name": "Item Group",

View File

@ -3,7 +3,8 @@
"doctype": "Item Group", "doctype": "Item Group",
"is_group": "No", "is_group": "No",
"item_group_name": "_Test Item Group", "item_group_name": "_Test Item Group",
"parent_item_group": "All Item Groups" "parent_item_group": "All Item Groups",
"default_cost_center": "_Test Cost Center 2 - _TC"
}, },
{ {
"doctype": "Item Group", "doctype": "Item Group",

View File

@ -27,7 +27,7 @@ class TestItem(unittest.TestCase):
"warehouse": "_Test Warehouse - _TC", "warehouse": "_Test Warehouse - _TC",
"income_account": "Sales - _TC", "income_account": "Sales - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC", "expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center 2 - _TC",
"qty": 1.0, "qty": 1.0,
"price_list_rate": 100.0, "price_list_rate": 100.0,
"base_price_list_rate": 0.0, "base_price_list_rate": 0.0,

View File

@ -28,7 +28,6 @@
"warehouse_reorder_qty": 20 "warehouse_reorder_qty": 20
} }
], ],
"selling_cost_center": "_Test Cost Center - _TC",
"stock_uom": "_Test UOM", "stock_uom": "_Test UOM",
"show_in_website": 1, "show_in_website": 1,
"website_warehouse": "_Test Warehouse - _TC" "website_warehouse": "_Test Warehouse - _TC"

View File

@ -35,6 +35,7 @@ def get_item_details(args):
item_doc = frappe.get_doc("Item", args.item_code) item_doc = frappe.get_doc("Item", args.item_code)
item = item_doc item = item_doc
validate_item_details(args, item) validate_item_details(args, item)
out = get_basic_details(args, item_doc) 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 "" if len(user_default_warehouse_list)==1 else ""
out = frappe._dict({ out = frappe._dict({
"item_code": item.name, "item_code": item.name,
"item_name": item.item_name, "item_name": item.item_name,
"description": item.description_html or item.description, "description": item.description_html or item.description,
"warehouse": user_default_warehouse or args.warehouse or item.default_warehouse, "warehouse": user_default_warehouse or args.warehouse or item.default_warehouse,
"income_account": item.income_account or args.income_account \ "income_account": (item.income_account
or frappe.db.get_value("Company", args.company, "default_income_account"), or args.income_account
"expense_account": item.expense_account or args.expense_account \ or frappe.db.get_value("Item Group", item.item_group, "default_income_account")
or frappe.db.get_value("Company", args.company, "default_expense_account"), or frappe.db.get_value("Company", args.company, "default_income_account")),
"cost_center": item.selling_cost_center \ "expense_account": (item.expense_account
if args.transaction_type == "selling" else item.buying_cost_center, 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, "batch_no": None,
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
item_doc.get("item_tax")))), item_doc.get("item_tax")))),
@ -174,6 +181,7 @@ def get_price_list_rate(args, item_doc, out):
validate_price_list(args) validate_price_list(args)
validate_conversion_rate(args, meta) validate_conversion_rate(args, meta)
price_list_rate = frappe.db.get_value("Item Price", price_list_rate = frappe.db.get_value("Item Price",
{"price_list": args.price_list, "item_code": args.item_code}, "price_list_rate") {"price_list": args.price_list, "item_code": args.item_code}, "price_list_rate")