'Create production order. Called from Production Planning Tool'

def create_production_order(self, item_dict):

    from erpnext.manufacturing.doctype.production_order.production_order import OverProductionError, get_default_warehouse
    warehouse = get_default_warehouse()
    pro = frappe.new_doc(u'Production    Order')
    pro.update(item_dict)
    pro.set_production_order_operations()
    if warehouse:
        pro.wip_warehouse = warehouse.get(u'wip_warehouse')
    if (not pro.fg_warehouse):
        pro.fg_warehouse = warehouse.get(u'fg_warehouse')
    try:
        pro.insert()
        return pro.name
    except OverProductionError:
        pass
