From 096fc8820080757adf6dd1a1140690ee721b50a6 Mon Sep 17 00:00:00 2001 From: gabtzi Date: Mon, 28 Dec 2015 11:07:10 +0200 Subject: [PATCH] Fix for Issue #4543: Improved code to check if it's a variant only once. --- erpnext/stock/doctype/item/item.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 12c39dbdc3..830e62d549 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -30,14 +30,15 @@ class Item(WebsiteGenerator): self.get("__onload").sle_exists = self.check_if_sle_exists() def autoname(self): - if frappe.db.get_default("item_naming_by")=="Naming Series" and not self.variant_of: - from frappe.model.naming import make_autoname - self.item_code = make_autoname(self.naming_series+'.#####') - elif frappe.db.get_default("item_naming_by")=="Naming Series" and self.variant_of: - item_code_suffix = "" - for attribute in self.attributes: - item_code_suffix += "-" + str(attribute.attribute_value) - self.item_code = str(self.variant_of) + item_code_suffix + if frappe.db.get_default("item_naming_by")=="Naming Series": + if self.variant_of: + item_code_suffix = "" + for attribute in self.attributes: + item_code_suffix += "-" + str(attribute.attribute_value) + self.item_code = str(self.variant_of) + item_code_suffix + else: + from frappe.model.naming import make_autoname + self.item_code = make_autoname(self.naming_series+'.#####') elif not self.item_code: msgprint(_("Item Code is mandatory because Item is not automatically numbered"), raise_exception=1)