From 51ff2658cb4e674f03263b96272a488a168af5fe Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 31 Dec 2015 15:48:48 +0530 Subject: [PATCH] [fix] Minor changes in item naming --- erpnext/stock/doctype/item/item.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 67f3a25376..fe13fa17ea 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -32,11 +32,13 @@ class Item(WebsiteGenerator): def autoname(self): if frappe.db.get_default("item_naming_by")=="Naming Series": if self.variant_of: - item_code_suffix = "" - for attribute in self.attributes: - attribute_abbr = frappe.db.get_value("Item Attribute Value", {"parent": attribute.attribute, "attribute_value": attribute.attribute_value}, "abbr") - item_code_suffix += "-" + str(attribute_abbr or attribute.attribute_value) - self.item_code = str(self.variant_of) + item_code_suffix + if not self.item_code: + item_code_suffix = "" + for attribute in self.attributes: + attribute_abbr = frappe.db.get_value("Item Attribute Value", + {"parent": attribute.attribute, "attribute_value": attribute.attribute_value}, "abbr") + item_code_suffix += "-" + str(attribute_abbr or 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+'.#####')