set variant name based on template name (frappe/erpnext#6367) (#8920)
diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py
index 53421b7..3349303 100644
--- a/erpnext/controllers/item_variant.py
+++ b/erpnext/controllers/item_variant.py
@@ -165,7 +165,7 @@
variant.set("attributes", variant_attributes)
copy_attributes_to_variant(template, variant)
- make_variant_item_code(template.item_code, variant)
+ make_variant_item_code(template.item_code, template.item_name, variant)
return variant
@@ -194,7 +194,7 @@
for d in variant.attributes:
variant.description += "<p>" + d.attribute + ": " + cstr(d.attribute_value) + "</p>"
-def make_variant_item_code(template_item_code, variant):
+def make_variant_item_code(template_item_code, template_item_name, variant):
"""Uses template's item code and abbreviations to make variant's item code"""
if variant.item_code:
return
@@ -220,6 +220,4 @@
if abbreviations:
variant.item_code = "{0}-{1}".format(template_item_code, "-".join(abbreviations))
-
- if variant.item_code:
- variant.item_name = variant.item_code
+ variant.item_name = "{0}-{1}".format(template_item_name, "-".join(abbreviations))