diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index acaa0966a2..1c3375050e 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -129,6 +129,8 @@ def _make_test_records(verbose): ["_Test Write Off", "Indirect Expenses", 0, None, None], ["_Test Exchange Gain/Loss", "Indirect Expenses", 0, None, None], + ["_Test Account Sales", "Direct Income", 0, None, None], + # related to Account Inventory Integration ["_Test Account Stock In Hand", "Current Assets", 0, None, None], diff --git a/erpnext/setup/doctype/brand/test_records.json b/erpnext/setup/doctype/brand/test_records.json index d2a4ad4e23..17b5a6b0a3 100644 --- a/erpnext/setup/doctype/brand/test_records.json +++ b/erpnext/setup/doctype/brand/test_records.json @@ -2,5 +2,16 @@ { "brand": "_Test Brand", "doctype": "Brand" + }, + { + "brand": "_Test Brand With Item Defaults", + "doctype": "Brand", + "brand_defaults": [{ + "company": "_Test Company", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "income_account": "_Test Account Sales - _TC", + "buying_cost_center": "_Test Cost Center - _TC", + "selling_cost_center": "_Test Cost Center - _TC" + }] } ] \ No newline at end of file diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index d02559ebcb..6ec7ba1d1f 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -102,6 +102,61 @@ class TestItem(unittest.TestCase): for key, value in iteritems(to_check): self.assertEqual(value, details.get(key)) + def test_item_defaults(self): + frappe.delete_doc_if_exists("Item", "Test Item With Defaults", force=1) + make_item("Test Item With Defaults", { + "item_group": "_Test Item Group", + "brand": "_Test Brand With Item Defaults", + "item_defaults": [{ + "company": "_Test Company", + "default_warehouse": "_Test Warehouse 2 - _TC", # no override + "expense_account": "_Test Account Stock Expenses - _TC", # override brand default + "buying_cost_center": "_Test Write Off Cost Center - _TC", # override item group default + }] + }) + + sales_item_check = { + "item_code": "Test Item With Defaults", + "warehouse": "_Test Warehouse 2 - _TC", # from item + "income_account": "_Test Account Sales - _TC", # from brand + "expense_account": "_Test Account Stock Expenses - _TC", # from item + "cost_center": "_Test Cost Center 2 - _TC", # from item group + } + sales_item_details = get_item_details({ + "item_code": "Test Item With Defaults", + "company": "_Test Company", + "price_list": "_Test Price List", + "currency": "_Test Currency", + "doctype": "Sales Invoice", + "conversion_rate": 1, + "price_list_currency": "_Test Currency", + "plc_conversion_rate": 1, + "customer": "_Test Customer", + }) + for key, value in iteritems(sales_item_check): + self.assertEqual(value, sales_item_details.get(key)) + + purchase_item_check = { + "item_code": "Test Item With Defaults", + "warehouse": "_Test Warehouse 2 - _TC", # from item + "expense_account": "_Test Account Stock Expenses - _TC", # from item + "income_account": "_Test Account Sales - _TC", # from brand + "cost_center": "_Test Write Off Cost Center - _TC" # from item + } + purchase_item_details = get_item_details({ + "item_code": "Test Item With Defaults", + "company": "_Test Company", + "price_list": "_Test Price List", + "currency": "_Test Currency", + "doctype": "Purchase Invoice", + "conversion_rate": 1, + "price_list_currency": "_Test Currency", + "plc_conversion_rate": 1, + "supplier": "_Test Supplier", + }) + for key, value in iteritems(purchase_item_check): + self.assertEqual(value, purchase_item_details.get(key)) + def test_item_attribute_change_after_variant(self): frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1)