fix: variant item description based on attribute (#17627)

* fix: variant item description based on attribute

* fix: requested changes

* style: removed print
This commit is contained in:
Anurag Mishra
2019-05-16 13:57:35 +05:30
committed by GitHub
parent cc4f13a862
commit 8e9413829d

View File

@@ -287,19 +287,15 @@ def copy_attributes_to_variant(item, variant):
variant.set(field.fieldname, item.get(field.fieldname))
variant.variant_of = item.name
if 'description' in allow_fields:
variant.has_variants = 0
if not variant.description:
variant.description = ""
if item.variant_based_on=='Item Attribute':
if variant.attributes:
attributes_description = ""
for d in variant.attributes:
attributes_description += "<div>" + d.attribute + ": " + cstr(d.attribute_value) + "</div>"
if not variant.description:
variant.description = ""
if attributes_description not in variant.description:
variant.description += attributes_description
if 'description' not in allow_fields:
if item.variant_based_on == 'Item Attribute' and not variant.description:
variant.description = "<div><b>" + item.name + "</b></div>"
for d in variant.attributes:
variant.description += "<div><b>" + d.attribute + "</b>: " + cstr(d.attribute_value) + "</div>"
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"""