'Add items to Flat BOM table'

def add_exploded_items(self):

    frappe.db.sql(u'delete    from    `tabBOM    Explosion    Item`    where    parent=%s', self.name)
    self.set(u'exploded_items', [])
    for d in sorted(self.cur_exploded_items, key=itemgetter(0)):
        ch = self.append(u'exploded_items', {})
        for i in self.cur_exploded_items[d].keys():
            ch.set(i, self.cur_exploded_items[d][i])
        ch.amount = (flt(ch.stock_qty) * flt(ch.rate))
        ch.qty_consumed_per_unit = (flt(ch.stock_qty) / flt(self.quantity))
        ch.docstatus = self.docstatus
        ch.db_insert()
