Subversion Repositories SmartDukaan

Rev

Rev 4062 | Rev 4103 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4062 Rev 4064
Line 1219... Line 1219...
1219
def get_pending_orders_inventory(vendor_id=1):
1219
def get_pending_orders_inventory(vendor_id=1):
1220
    """
1220
    """
1221
    Returns a list of inventory stock for items for which there are pending orders.
1221
    Returns a list of inventory stock for items for which there are pending orders.
1222
    """
1222
    """
1223
    warehouse_ids = [warehouse.id for warehouse in Warehouse.query.filter_by(vendor_id=vendor_id).all()]
1223
    warehouse_ids = [warehouse.id for warehouse in Warehouse.query.filter_by(vendor_id=vendor_id).all()]
-
 
1224
    pending_items_inventory = []
-
 
1225
    if warehouse_ids:
1224
    pending_items_inventory = session.query(CurrentInventorySnapshot.item_id, func.sum(CurrentInventorySnapshot.availibility), func.sum(CurrentInventorySnapshot.reserved)).filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).group_by(CurrentInventorySnapshot.item_id).having(func.sum(CurrentInventorySnapshot.reserved) > 0).all()
1226
        pending_items_inventory = session.query(CurrentInventorySnapshot.item_id, func.sum(CurrentInventorySnapshot.availibility), func.sum(CurrentInventorySnapshot.reserved)).filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).group_by(CurrentInventorySnapshot.item_id).having(func.sum(CurrentInventorySnapshot.reserved) > 0).all()
1225
    return pending_items_inventory
1227
    return pending_items_inventory
1226
    
1228
    
1227
def close_session():
1229
def close_session():
1228
    if session.is_active:
1230
    if session.is_active:
1229
        print "session is active. closing it."
1231
        print "session is active. closing it."