Created
September 5, 2013 21:40
-
-
Save aliomattux/6456571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_bins(self, cr, uid, bin_selection, storage_type, list_exclusions, qty_dict, context=None): | |
base_sql = "SELECT DISTINCT bin.id " \ | |
"\nFROM stock_location_bin bin " \ | |
"\nLEFT JOIN stock_inventory stock ON stock.bin_id = bin.id" | |
first = True | |
if bin_selection == 'empty': | |
if first: | |
first = False | |
operator = ' WHERE' | |
else: | |
operator = ' AND' | |
base_sql += "\n%s stock.bin_id IS NULL" % operator | |
elif bin_selection == 'not_empty': | |
if first: | |
first = False | |
operator = ' WHERE' | |
else: | |
operator = ' AND' | |
base_sql += "\n%s stock.bin_id IS NOT NULL" % operator | |
if storage_type and storage_type != 'all': | |
if first: | |
first = False | |
operator = ' WHERE' | |
else: | |
operator = ' AND' | |
base_sql += " \n%s bin.storage_type = '%s'" % (operator, storage_type) | |
if list_exclusions and list_exclusions != []: | |
if len(list_exclusions) == 1: | |
query += "\nAND bin.id != %s" % str(list_exclusions[0]) | |
else: | |
query += "\nAND bin.id NOT IN %s" % str(tuple(list_exclusions)) | |
if qty_dict: | |
if first: | |
first = False | |
operator = ' WHERE' | |
else: | |
operator = ' AND' | |
base_sql += "\n%s stock.qty_onhand %s %s" % (operator, qty_dict['operator'], qty_dict['value']) | |
return base_sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment