Highlight SRP in red, if reg price is greater (in products grid)

seems like a good enough idea generally...
This commit is contained in:
Lance Edgar 2020-01-14 16:35:30 -06:00
parent bbd462c85a
commit 8f07f27a61

View file

@ -305,6 +305,9 @@ class ProductsView(MasterView):
g.set_sorter('current_price', self.CurrentPrice.price)
g.set_filter('current_price', self.CurrentPrice.price, label="Current Price")
# suggested_price
g.set_renderer('suggested_price', self.render_grid_suggested_price)
# (unit) cost
g.set_joiner('cost', lambda q: q.outerjoin(model.ProductCost,
sa.and_(
@ -518,6 +521,18 @@ class ProductsView(MasterView):
else: # not buefy
return self.add_price_history_link(text, 'suggested')
def render_grid_suggested_price(self, product, field):
text = self.render_price(product, field)
if not text:
return ""
sugprice = product.suggested_price.price if product.suggested_price else None
regprice = product.regular_price.price if product.regular_price else None
if sugprice and regprice and sugprice < regprice:
return HTML.tag('div', style='color: red;', c=text)
return text
def render_true_cost(self, product, field):
if not product.volatile:
return ""