Add sorters, filters for Product regular, current price
This commit is contained in:
parent
c320ab2feb
commit
aea4379fe4
|
@ -100,6 +100,10 @@ class ProductsView(MasterView):
|
|||
ProductCostAny = orm.aliased(model.ProductCost)
|
||||
VendorAny = orm.aliased(model.Vendor)
|
||||
|
||||
# same, but for prices
|
||||
RegularPrice = orm.aliased(model.ProductPrice)
|
||||
CurrentPrice = orm.aliased(model.ProductPrice)
|
||||
|
||||
def __init__(self, request):
|
||||
super(ProductsView, self).__init__(request)
|
||||
self.print_labels = request.rattail_config.getbool('tailbone', 'products.print_labels', default=False)
|
||||
|
@ -146,7 +150,6 @@ class ProductsView(MasterView):
|
|||
.outerjoin(self.VendorAny,
|
||||
self.VendorAny.uuid == self.ProductCostAny.vendor_uuid)
|
||||
|
||||
|
||||
ProductCostCode = orm.aliased(model.ProductCost)
|
||||
ProductCostCodeAny = orm.aliased(model.ProductCost)
|
||||
|
||||
|
@ -167,10 +170,6 @@ class ProductsView(MasterView):
|
|||
g.joiners['subdepartment'] = lambda q: q.outerjoin(model.Subdepartment,
|
||||
model.Subdepartment.uuid == model.Product.subdepartment_uuid)
|
||||
g.joiners['report_code'] = lambda q: q.outerjoin(model.ReportCode)
|
||||
g.joiners['regular_price'] = lambda q: q.outerjoin(model.ProductPrice,
|
||||
model.ProductPrice.uuid == model.Product.regular_price_uuid)
|
||||
g.joiners['current_price'] = lambda q: q.outerjoin(model.ProductPrice,
|
||||
model.ProductPrice.uuid == model.Product.current_price_uuid)
|
||||
g.joiners['code'] = lambda q: q.outerjoin(model.ProductCode)
|
||||
g.joiners['vendor'] = join_vendor
|
||||
g.joiners['vendor_any'] = join_vendor_any
|
||||
|
@ -209,6 +208,18 @@ class ProductsView(MasterView):
|
|||
g.sorters['cost'] = g.make_sorter(model.ProductCost.unit_cost)
|
||||
g.filters['cost'] = g.make_filter('cost', model.ProductCost.unit_cost)
|
||||
|
||||
g.set_label('regular_price', "Reg. Price")
|
||||
g.set_joiner('regular_price', lambda q: q.outerjoin(
|
||||
self.RegularPrice, self.RegularPrice.uuid == model.Product.regular_price_uuid))
|
||||
g.set_sorter('regular_price', self.RegularPrice.price)
|
||||
g.set_filter('regular_price', self.RegularPrice.price, label="Regular Price")
|
||||
|
||||
g.set_label('current_price', "Cur. Price")
|
||||
g.set_joiner('current_price', lambda q: q.outerjoin(
|
||||
self.CurrentPrice, self.CurrentPrice.uuid == model.Product.current_price_uuid))
|
||||
g.set_sorter('current_price', self.CurrentPrice.price)
|
||||
g.set_filter('current_price', self.CurrentPrice.price, label="Current Price")
|
||||
|
||||
g.default_sortkey = 'upc'
|
||||
|
||||
if self.print_labels and self.request.has_perm('products.print_labels'):
|
||||
|
@ -229,8 +240,6 @@ class ProductsView(MasterView):
|
|||
g.set_label('upc', "UPC")
|
||||
g.set_label('vendor', "Vendor (preferred)")
|
||||
g.set_label('vendor_any', "Vendor (any)")
|
||||
g.set_label('regular_price', "Reg. Price")
|
||||
g.set_label('current_price', "Cur. Price")
|
||||
g.set_label('vendor', "Pref. Vendor")
|
||||
|
||||
def render_price(self, product, column):
|
||||
|
|
Loading…
Reference in a new issue