[fix] Minor changes in item naming

This commit is contained in:
Nabin Hait 2015-12-31 15:48:48 +05:30
parent dd1c3ba164
commit 51ff2658cb

View File

@ -32,11 +32,13 @@ class Item(WebsiteGenerator):
def autoname(self): def autoname(self):
if frappe.db.get_default("item_naming_by")=="Naming Series": if frappe.db.get_default("item_naming_by")=="Naming Series":
if self.variant_of: if self.variant_of:
item_code_suffix = "" if not self.item_code:
for attribute in self.attributes: item_code_suffix = ""
attribute_abbr = frappe.db.get_value("Item Attribute Value", {"parent": attribute.attribute, "attribute_value": attribute.attribute_value}, "abbr") for attribute in self.attributes:
item_code_suffix += "-" + str(attribute_abbr or attribute.attribute_value) attribute_abbr = frappe.db.get_value("Item Attribute Value",
self.item_code = str(self.variant_of) + item_code_suffix {"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: else:
from frappe.model.naming import make_autoname from frappe.model.naming import make_autoname
self.item_code = make_autoname(self.naming_series+'.#####') self.item_code = make_autoname(self.naming_series+'.#####')