def make_variant_item_code(template_item_code, variant):
 if variant.item_code:
  return
 abbreviations = []
 for attr in variant.attributes:
  item_attribute = frappe.db.sql(u'select i.numeric_values, v.abbr\n DCTB  DCTB  DCTB from `tabItem Attribute` i left join `tabItem Attribute Value` v\n DCTB  DCTB  DCTB  DCTB on (i.name=v.parent)\n DCTB  DCTB  DCTB where i.name=%(attribute)s and v.attribute_value=%(attribute_value)s', {u'attribute': attr.attribute, u'attribute_value': attr.attribute_value}, as_dict=True)
  if (not item_attribute):
   return
  if item_attribute[0].numeric_values:
   return
  abbreviations.append(item_attribute[0].abbr)
 if abbreviations:
  variant.item_code = u'{0}-{1}'.format(template_item_code, u'-'.join(abbreviations))
 if variant.item_code:
  variant.item_name = variant.item_code

def make_variant_item_code ( template_item_code , variant ) : if variant . item_code : return abbreviations = [ ] for attr in variant . attributes : item_attribute = frappe . db . sql ( u'select i.numeric_values, v.abbr\n DCTB  DCTB  DCTB from `tabItem Attribute` i left join `tabItem Attribute Value` v\n DCTB  DCTB  DCTB  DCTB on (i.name=v.parent)\n DCTB  DCTB  DCTB where i.name=%(attribute)s and v.attribute_value=%(attribute_value)s' , { u'attribute' : attr . attribute , u'attribute_value' : attr . attribute_value } , as_dict = True ) if ( not item_attribute ) : return if item_attribute [ 0 ] . numeric_values : return abbreviations . append ( item_attribute [ 0 ] . abbr ) if abbreviations : variant . item_code = u'{0}-{1}' . format ( template_item_code , u'-' . join ( abbreviations ) ) if variant . item_code : variant . item_name = variant . item_code
uses templates item code and abbreviations to make variants item code .