'set opening stock'

def set_opening_stock(self):

    if ((not self.is_stock_item) or self.has_serial_no or self.has_batch_no):
        return
    if ((not self.valuation_rate) and self.standard_rate):
        self.valuation_rate = self.standard_rate
    if (not self.valuation_rate):
        frappe.throw(_(u'Valuation    Rate    is    mandatory    if    Opening    Stock    entered'))
    from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
    default_warehouse = (self.default_warehouse or frappe.db.get_single_value(u'Stock    Settings', u'default_warehouse') or frappe.db.get_value(u'Warehouse', {u'warehouse_name': _(u'Stores')}))
    if default_warehouse:
        stock_entry = make_stock_entry(item_code=self.name, target=default_warehouse, qty=self.opening_stock, rate=self.valuation_rate)
        stock_entry.add_comment(u'Comment', _(u'Opening    Stock'))
