Allow location name lookup, fix search typo

This commit is contained in:
2026-04-13 12:25:09 -05:00
parent f793bd01e1
commit 971cf8d6b6

View File

@@ -307,11 +307,12 @@ def checkout(user, barcode, loc=None):
loc = None loc = None
if itm: if itm:
itm.checkout = True itm.checkout = True
if user is not False:
itm.checkout_user = user itm.checkout_user = user
itm.checkout_loc = loc itm.checkout_loc = loc
itm.save() itm.save()
itmdict = item.select().where(item.barcode==itm.barcode).dicts()[0] itmdict = item.select().where(item.barcode==itm.barcode).dicts()[0]
itmdict["location"] = fancy_location(item.select().where(item.barcode==itm["barcode"])[0].loc) itmdict["location"] = fancy_location(item.select().where(item.barcode==itmdict["barcode"])[0].loc)
search.add_document(itmdict) search.add_document(itmdict)
return itm return itm
else: else:
@@ -324,12 +325,13 @@ def checkin(user, barcode, loc=None):
if itm: if itm:
print("Found", itm.fullname) print("Found", itm.fullname)
itm.checkout = False itm.checkout = False
if user is not False:
itm.last_user = user itm.last_user = user
if loc is not None: if loc is not None:
itm.loc = loc itm.loc = loc
itm.save() itm.save()
itmdict = item.select().where(item.barcode==itm.barcode).dicts()[0] itmdict = item.select().where(item.barcode==itm.barcode).dicts()[0]
itmdict["location"] = fancy_location(item.select().where(item.barcode==itm["barcode"])[0].loc) itmdict["location"] = fancy_location(item.select().where(item.barcode==itmdict["barcode"])[0].loc)
search.add_document(itmdict) search.add_document(itmdict)
return itm return itm
else: else:
@@ -382,6 +384,8 @@ def get_location_id(barcode):
#print(loc.name, loc.locationid) #print(loc.name, loc.locationid)
if loc.locationid == barcode: if loc.locationid == barcode:
return loc return loc
elif loc.name == barcode:
return loc
return False return False
else: else:
return False return False