Subversion Repositories SmartDukaan

Rev

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

Rev 4024 Rev 4062
Line 1214... Line 1214...
1214
            res = opener.open(top_level_url + "cache-admin/HomePageSnippets?_method=delete")
1214
            res = opener.open(top_level_url + "cache-admin/HomePageSnippets?_method=delete")
1215
            print "Successfully cleared home page cache" + res.read()
1215
            print "Successfully cleared home page cache" + res.read()
1216
    except:
1216
    except:
1217
        print "Unable to clear cache, still should continue with other operations"
1217
        print "Unable to clear cache, still should continue with other operations"
1218
        
1218
        
1219
def get_pending_orders_inventory():
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
    pending_items_inventory = session.query(CurrentInventorySnapshot.item_id, func.sum(CurrentInventorySnapshot.availibility), func.sum(CurrentInventorySnapshot.reserved)).group_by(CurrentInventorySnapshot.item_id).having(func.sum(CurrentInventorySnapshot.reserved) > 0).all()
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()
1224
    return pending_items_inventory
1225
    return pending_items_inventory
1225
    
1226
    
1226
def close_session():
1227
def close_session():
1227
    if session.is_active:
1228
    if session.is_active:
1228
        print "session is active. closing it."
1229
        print "session is active. closing it."