diff --git a/rattail/pyramid/templates/autocomplete.mako b/rattail/pyramid/templates/autocomplete.mako
new file mode 100644
index 00000000..e9548794
--- /dev/null
+++ b/rattail/pyramid/templates/autocomplete.mako
@@ -0,0 +1,44 @@
+<%def name="autocomplete(field_name, service_url, field_value=None, field_display=None, width='300px', selected=None, cleared=None)">
+
+ ${h.hidden(field_name, id=field_name, value=field_value)}
+ ${h.text(field_name+'-textbox', id=field_name+'-textbox', value=field_display,
+ class_='autocomplete-textbox', style='display: none;' if field_value else '')}
+
+ ${field_display or ''}
+
+
+
+
+%def>
diff --git a/rattail/pyramid/views/autocomplete.py b/rattail/pyramid/views/autocomplete.py
index abb76b3c..372320b5 100644
--- a/rattail/pyramid/views/autocomplete.py
+++ b/rattail/pyramid/views/autocomplete.py
@@ -38,15 +38,15 @@ class AutocompleteView(View):
def filter_query(self, q):
return q
- def make_query(self, query):
+ def make_query(self, term):
q = Session.query(self.mapped_class)
q = self.filter_query(q)
- q = q.filter(getattr(self.mapped_class, self.fieldname).ilike('%%%s%%' % query))
+ q = q.filter(getattr(self.mapped_class, self.fieldname).ilike('%%%s%%' % term))
q = q.order_by(getattr(self.mapped_class, self.fieldname))
return q
- def query(self, query):
- return self.make_query(query)
+ def query(self, term):
+ return self.make_query(term)
def display(self, instance):
return getattr(instance, self.fieldname)
diff --git a/rattail/pyramid/views/departments.py b/rattail/pyramid/views/departments.py
index ecc19c84..d53d1615 100644
--- a/rattail/pyramid/views/departments.py
+++ b/rattail/pyramid/views/departments.py
@@ -27,9 +27,9 @@
"""
-from edbob.pyramid.views import (
- SearchableAlchemyGridView, CrudView, AlchemyGridView, AutocompleteView)
+from edbob.pyramid.views import SearchableAlchemyGridView, CrudView, AlchemyGridView
+from rattail.pyramid.views import AutocompleteView
from rattail.db.model import Department, Product, ProductCost, Vendor