Added support for product codes.

These are shown when viewing a product, and may be used to locate a product via
search filters.
This commit is contained in:
Lance Edgar 2013-06-09 13:03:42 -07:00
parent c7995c5241
commit fec34d8290
2 changed files with 27 additions and 2 deletions

View file

@ -4,6 +4,28 @@ ${parent.body()}
<% product = form.fieldset.model %> <% product = form.fieldset.model %>
<div id="product-codes">
<h2>Product Codes:</h2>
% if product.codes:
<div class="grid hoverable">
<table>
<thead>
<th>Code</th>
</thead>
<tbody>
% for i, code in enumerate(product.codes, 1):
<tr class="${'odd' if i % 2 else 'even'}">
<td>${code}</td>
</tr>
% endfor
</tbody>
</table>
</div>
% else:
<p>None on file.</p>
% endif
</div>
<div id="product-costs"> <div id="product-costs">
<h2>Product Costs:</h2> <h2>Product Costs:</h2>
% if product.costs: % if product.costs:

View file

@ -44,7 +44,7 @@ from rattail import sil
from rattail import batches from rattail import batches
from rattail.threads import Thread from rattail.threads import Thread
from rattail.exceptions import LabelPrintingError from rattail.exceptions import LabelPrintingError
from rattail.db.model import ProductPrice from rattail.db.model import ProductPrice, ProductCode
from rattail.pyramid import Session from rattail.pyramid import Session
from rattail.pyramid.forms import (AutocompleteFieldRenderer, from rattail.pyramid.forms import (AutocompleteFieldRenderer,
@ -87,6 +87,8 @@ class ProductsGrid(SearchableAlchemyGridView):
rattail.ProductPrice.uuid == rattail.Product.current_price_uuid), rattail.ProductPrice.uuid == rattail.Product.current_price_uuid),
'vendor': 'vendor':
join_vendor, join_vendor,
'code':
lambda q: q.outerjoin(ProductCode),
} }
def filter_map(self): def filter_map(self):
@ -117,7 +119,8 @@ class ProductsGrid(SearchableAlchemyGridView):
brand=self.filter_ilike(rattail.Brand.name), brand=self.filter_ilike(rattail.Brand.name),
department=self.filter_ilike(rattail.Department.name), department=self.filter_ilike(rattail.Department.name),
subdepartment=self.filter_ilike(rattail.Subdepartment.name), subdepartment=self.filter_ilike(rattail.Subdepartment.name),
vendor=self.filter_ilike(rattail.Vendor.name)) vendor=self.filter_ilike(rattail.Vendor.name),
code=self.filter_ilike(ProductCode.code))
def filter_config(self): def filter_config(self):
return self.make_filter_config( return self.make_filter_config(