Add "exclude not for sale" option to Inventory Worksheet.

This commit is contained in:
Lance Edgar 2014-09-11 20:59:43 -07:00
parent dfb5e83c7e
commit a3cfbd1e09
2 changed files with 15 additions and 8 deletions

View file

@ -19,8 +19,12 @@ ${h.form(request.current_route_url())}
</div>
</div>
<div class="field">
${h.checkbox('weighted-only', label=h.literal("Include items sold by weight <strong>only</strong>."))}
<div class="field-wrapper">
${h.checkbox('weighted-only', label="Only include items which are sold by weight.")}
</div>
<div class="field-wrapper">
${h.checkbox('exclude-not-for-sale', label="Exclude items marked \"not for sale\".", checked=True)}
</div>
<div class="buttons">

View file

@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2012 Lance Edgar
# Copyright © 2010-2014 Lance Edgar
#
# This file is part of Rattail.
#
@ -26,6 +25,8 @@
Report Views
"""
from __future__ import unicode_literals
import re
from .core import View
@ -147,9 +148,9 @@ class InventoryWorksheet(View):
department = departments.get(self.request.params['department'])
if department:
body = self.write_report(department)
response = Response(content_type='text/html')
response.headers['Content-Length'] = len(body)
response.headers['Content-Disposition'] = 'attachment; filename=inventory.html'
response = Response(content_type=b'text/html')
response.headers[b'Content-Length'] = len(body)
response.headers[b'Content-Disposition'] = b'attachment; filename=inventory.html'
response.text = body
return response
@ -168,6 +169,8 @@ class InventoryWorksheet(View):
q = q.filter(model.Product.subdepartment == subdepartment)
if self.request.params.get('weighted-only'):
q = q.filter(model.Product.unit_of_measure == enum.UNIT_OF_MEASURE_POUND)
if self.request.params.get('exclude-not-for-sale'):
q = q.filter(model.Product.not_for_sale == False)
q = q.order_by(model.Brand.name, model.Product.description)
return q.all()