'Validate raw material entries'

def validate_materials(self):

    def get_duplicates(lst):
        seen = set()
        seen_add = seen.add
        for item in lst:
            if ((item.item_code in seen) or seen_add(item.item_code)):
                (yield item)
    if (not self.get(u'items')):
        frappe.throw(_(u'Raw    Materials    cannot    be    blank.'))
    check_list = []
    for m in self.get(u'items'):
        if m.bom_no:
            validate_bom_no(m.item_code, m.bom_no)
        if (flt(m.stock_qty) <= 0):
            frappe.throw(_(u'Quantity    required    for    Item    {0}    in    row    {1}').format(m.item_code, m.idx))
        check_list.append(m)
    duplicate_items = list(get_duplicates(check_list))
    if duplicate_items:
        li = []
        for i in duplicate_items:
            li.append(u'{0}    on    row    {1}'.format(i.item_code, i.idx))
        duplicate_list = (u'<br>' + u'<br>'.join(li))
        frappe.throw(_(u'Same    item    has    been    entered    multiple    times.    {list}').format(list=duplicate_list))
