Search functionality added to Stock Management.

This commit is contained in:
Nephirus 2013-02-23 15:18:20 +01:00
parent fb6eadf031
commit ba4d8686f6
3 changed files with 94 additions and 9 deletions

View file

@ -131,10 +131,11 @@ class Shop:
def inventory_balance_str(self):
return self.currency.str(self.inventory_balance())
def account_list(self, acctype):
def account_list(self, acctype, like_str="%%"):
"""list all accounts (people or items, as per acctype)"""
accts = []
cur = self.db.execute_and_fetchall("SELECT id FROM accounts WHERE acctype = %s ORDER BY name ASC", [acctype])
cur = self.db.execute_and_fetchall("SELECT id FROM accounts WHERE acctype = %s AND name ILIKE %s ORDER BY name ASC", [acctype, like_str])
#FIXME: sanitize input like_str ^
for inventory in cur:
accts += [ Account.load(self.db, id = inventory[0]) ]
return accts