Add products row grid for misc. org table views

This commit is contained in:
Lance Edgar 2021-09-25 15:27:43 -04:00
parent ec5ff8a788
commit 0dc9793772
6 changed files with 236 additions and 18 deletions

View file

@ -171,6 +171,9 @@ class ProductView(MasterView):
super(ProductView, self).__init__(request)
self.print_labels = request.rattail_config.getbool('tailbone', 'products.print_labels', default=False)
app = self.get_rattail_app()
self.handler = app.get_products_handler()
def query(self, session):
user = self.request.user
if user and user not in session:
@ -453,24 +456,11 @@ class ProductView(MasterView):
return ""
return "${:0.2f}".format(cost.unit_cost)
def render_price(self, product, column):
price = product[column]
if price:
if not product.not_for_sale:
if price.price is not None and price.pack_price is not None:
if price.multiple > 1:
return HTML.literal("$ {:0.2f} / {}  ($ {:0.2f} / {})".format(
price.price, price.multiple,
price.pack_price, price.pack_multiple))
return HTML.literal("$ {:0.2f}  ($ {:0.2f} / {})".format(
price.price, price.pack_price, price.pack_multiple))
if price.price is not None:
if price.multiple is not None and price.multiple > 1:
return "$ {:0.2f} / {}".format(price.price, price.multiple)
return "$ {:0.2f}".format(price.price)
if price.pack_price is not None:
return "$ {:0.2f} / {}".format(price.pack_price, price.pack_multiple)
return ""
def render_price(self, product, field):
if not product.not_for_sale:
price = product[field]
if price:
return self.handler.render_price(price)
def render_current_price_for_grid(self, product, field):
text = self.render_price(product, field)