From 048e5f44b5b456e63f557bbfac1c121b62918d10 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 29 Mar 2019 14:33:48 +0530 Subject: [PATCH] fix(test): item variant --- erpnext/setup/doctype/brand/test_records.json | 2 +- erpnext/stock/doctype/item/item.py | 5 ++++- erpnext/stock/doctype/item/test_item.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/doctype/brand/test_records.json b/erpnext/setup/doctype/brand/test_records.json index 17b5a6b0a3..eeed9e7733 100644 --- a/erpnext/setup/doctype/brand/test_records.json +++ b/erpnext/setup/doctype/brand/test_records.json @@ -1,6 +1,6 @@ [ { - "brand": "_Test Brand", + "brand": "_Test Brand", "doctype": "Brand" }, { diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 73c009c7fb..43d7972196 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -791,6 +791,9 @@ class Item(WebsiteGenerator): d.conversion_factor = value def validate_attributes(self): + if not self.variant_based_on: + self.variant_based_on = 'Item Attribute' + if (self.has_variants or self.variant_of) and self.variant_based_on == 'Item Attribute': attributes = [] if not self.attributes: @@ -813,7 +816,7 @@ class Item(WebsiteGenerator): variant = get_variant(self.variant_of, args, self.name) if variant: frappe.throw(_("Item variant {0} exists with same attributes") - .format(variant), ItemVariantExistsError) + .format(variant), ItemVariantExistsError) validate_item_variant_attributes(self, args) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index b297f507b1..da53d8d6b1 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -18,7 +18,7 @@ from erpnext.stock.get_item_details import get_item_details from six import iteritems test_ignore = ["BOM"] -test_dependencies = ["Warehouse", "Item Group", "Item Tax Template"] +test_dependencies = ["Warehouse", "Item Group", "Item Tax Template", "Brand"] def make_item(item_code, properties=None): if frappe.db.exists("Item", item_code):