From 9710eede0001b0546c0eb9af84eb9bc23d49349e Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 13 Aug 2015 13:22:31 +0530 Subject: [PATCH] Fixed Test Cases --- erpnext/stock/doctype/item/item.py | 3 ++- erpnext/stock/doctype/item/test_item.py | 9 ++++++++- erpnext/stock/doctype/item/test_records.json | 5 +++++ erpnext/stock/doctype/stock_entry/test_stock_entry.py | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 5902c685f4..4b8aa1523b 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -539,7 +539,8 @@ def create_variant(item, param): "attribute_value": args[d] }) variant.set("attributes", variant_attributes) - copy_attributes_to_variant(item, variant) + template = frappe.get_doc("Item", item) + copy_attributes_to_variant(template, variant) return variant def copy_attributes_to_variant(item, variant): diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 9235becba1..8db2d2d61b 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -6,7 +6,7 @@ import unittest import frappe from frappe.test_runner import make_test_records -from erpnext.stock.doctype.item.item import WarehouseNotSet, ItemTemplateCannotHaveStock +from erpnext.stock.doctype.item.item import WarehouseNotSet, ItemTemplateCannotHaveStock, create_variant from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry test_ignore = ["BOM"] @@ -98,5 +98,12 @@ class TestItem(unittest.TestCase): for key, value in to_check.iteritems(): self.assertEquals(value, details.get(key)) + + def test_make_item_variant(self): + if not frappe.db.exists("Item", "_Test Variant Item-S"): + variant = create_variant("_Test Variant Item", """{"Test Size": "Small"}""") + variant.item_code = "_Test Variant Item-S" + variant.item_name = "_Test Variant Item-S" + variant.save() test_records = frappe.get_test_records('Item') diff --git a/erpnext/stock/doctype/item/test_records.json b/erpnext/stock/doctype/item/test_records.json index 5dd63e38de..f12c7cccf7 100644 --- a/erpnext/stock/doctype/item/test_records.json +++ b/erpnext/stock/doctype/item/test_records.json @@ -273,6 +273,11 @@ "item_name": "_Test Variant Item", "stock_uom": "_Test UOM", "has_variants": 1, + "attributes": [ + { + "attribute": "Test Size" + } + ], "apply_warehouse_wise_reorder_level": 1, "reorder_levels": [ { diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 03a2ffec35..29f2a21a01 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -67,6 +67,9 @@ class TestStockEntry(unittest.TestCase): def test_auto_material_request(self): self._test_auto_material_request("_Test Item") + + def test_auto_material_request_for_variant(self): + self._test_auto_material_request("_Test Variant Item-S") def _test_auto_material_request(self, item_code): item = frappe.get_doc("Item", item_code)