Sorted Ordering Worksheet by brand, description.

This commit is contained in:
Lance Edgar 2013-04-16 06:48:40 -07:00
parent bd700431f6
commit 9fabccd7ce
2 changed files with 8 additions and 1 deletions

View file

@ -104,7 +104,7 @@
<th>Pref.</th>
<th colspan="14">Order Scratch Pad</th>
</tr>
% for cost in sorted(costs[dept][subdept], key=lambda x: x.product.description):
% for cost in sorted(costs[dept][subdept], key=cost_sort_key):
<tr>
<td class="upc">${get_upc(cost.product)}</td>
<td class="brand">${cost.product.brand or ''}</td>

View file

@ -128,10 +128,17 @@ def write_ordering_worksheet(vendor, departments, preferred_only):
costs[dept].setdefault(subdept, [])
costs[dept][subdept].append(cost)
def cost_sort_key(cost):
product = cost.product
brand = product.brand.name if product.brand else ''
key = '{0} {1}'.format(brand, product.description)
return key
now = edbob.local_time()
data = dict(
vendor=vendor,
costs=costs,
cost_sort_key=cost_sort_key,
date=now.strftime('%a %d %b %Y'),
time=now.strftime('%I:%M %p'),
get_upc=get_upc,