Expose the Sale Price and TPR Price for product views
in addition to Current Price
This commit is contained in:
parent
47f6c941ec
commit
760fbc57bc
|
@ -191,6 +191,10 @@
|
||||||
${form.render_field_readonly('regular_price')}
|
${form.render_field_readonly('regular_price')}
|
||||||
${form.render_field_readonly('current_price')}
|
${form.render_field_readonly('current_price')}
|
||||||
${form.render_field_readonly('current_price_ends')}
|
${form.render_field_readonly('current_price_ends')}
|
||||||
|
${form.render_field_readonly('sale_price')}
|
||||||
|
${form.render_field_readonly('sale_price_ends')}
|
||||||
|
${form.render_field_readonly('tpr_price')}
|
||||||
|
${form.render_field_readonly('tpr_price_ends')}
|
||||||
${form.render_field_readonly('suggested_price')}
|
${form.render_field_readonly('suggested_price')}
|
||||||
${form.render_field_readonly('deposit_link')}
|
${form.render_field_readonly('deposit_link')}
|
||||||
${form.render_field_readonly('tax')}
|
${form.render_field_readonly('tax')}
|
||||||
|
|
|
@ -93,6 +93,8 @@ class ProductView(MasterView):
|
||||||
'tax1': "Tax 1",
|
'tax1': "Tax 1",
|
||||||
'tax2': "Tax 2",
|
'tax2': "Tax 2",
|
||||||
'tax3': "Tax 3",
|
'tax3': "Tax 3",
|
||||||
|
'tpr_price': "TPR Price",
|
||||||
|
'tpr_price_ends': "TPR Price Ends",
|
||||||
}
|
}
|
||||||
|
|
||||||
grid_columns = [
|
grid_columns = [
|
||||||
|
@ -131,6 +133,10 @@ class ProductView(MasterView):
|
||||||
'regular_price',
|
'regular_price',
|
||||||
'current_price',
|
'current_price',
|
||||||
'current_price_ends',
|
'current_price_ends',
|
||||||
|
'sale_price',
|
||||||
|
'sale_price_ends',
|
||||||
|
'tpr_price',
|
||||||
|
'tpr_price_ends',
|
||||||
'vendor',
|
'vendor',
|
||||||
'cost',
|
'cost',
|
||||||
'deposit_link',
|
'deposit_link',
|
||||||
|
@ -167,6 +173,8 @@ class ProductView(MasterView):
|
||||||
# same, but for prices
|
# same, but for prices
|
||||||
RegularPrice = orm.aliased(model.ProductPrice)
|
RegularPrice = orm.aliased(model.ProductPrice)
|
||||||
CurrentPrice = orm.aliased(model.ProductPrice)
|
CurrentPrice = orm.aliased(model.ProductPrice)
|
||||||
|
SalePrice = orm.aliased(model.ProductPrice)
|
||||||
|
TPRPrice = orm.aliased(model.ProductPrice)
|
||||||
|
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
super(ProductView, self).__init__(request)
|
super(ProductView, self).__init__(request)
|
||||||
|
@ -321,6 +329,16 @@ class ProductView(MasterView):
|
||||||
g.set_sorter('current_price', self.CurrentPrice.price)
|
g.set_sorter('current_price', self.CurrentPrice.price)
|
||||||
g.set_filter('current_price', self.CurrentPrice.price, label="Current Price")
|
g.set_filter('current_price', self.CurrentPrice.price, label="Current Price")
|
||||||
|
|
||||||
|
# tpr_price
|
||||||
|
g.set_joiner('tpr_price', lambda q: q.outerjoin(
|
||||||
|
self.TPRPrice, self.TPRPrice.uuid == model.Product.tpr_price_uuid))
|
||||||
|
g.set_filter('tpr_price', self.TPRPrice.price)
|
||||||
|
|
||||||
|
# sale_price
|
||||||
|
g.set_joiner('sale_price', lambda q: q.outerjoin(
|
||||||
|
self.SalePrice, self.SalePrice.uuid == model.Product.sale_price_uuid))
|
||||||
|
g.set_filter('sale_price', self.SalePrice.price)
|
||||||
|
|
||||||
# suggested_price
|
# suggested_price
|
||||||
g.set_renderer('suggested_price', self.render_grid_suggested_price)
|
g.set_renderer('suggested_price', self.render_grid_suggested_price)
|
||||||
|
|
||||||
|
@ -427,6 +445,34 @@ class ProductView(MasterView):
|
||||||
f.set_readonly('current_price_ends')
|
f.set_readonly('current_price_ends')
|
||||||
f.set_renderer('current_price_ends', self.render_current_price_ends)
|
f.set_renderer('current_price_ends', self.render_current_price_ends)
|
||||||
|
|
||||||
|
# sale_price
|
||||||
|
if self.creating:
|
||||||
|
f.remove_field('sale_price')
|
||||||
|
else:
|
||||||
|
f.set_readonly('sale_price')
|
||||||
|
f.set_renderer('sale_price', self.render_price)
|
||||||
|
|
||||||
|
# sale_price_ends
|
||||||
|
if self.creating:
|
||||||
|
f.remove_field('sale_price_ends')
|
||||||
|
else:
|
||||||
|
f.set_readonly('sale_price_ends')
|
||||||
|
f.set_renderer('sale_price_ends', self.render_sale_price_ends)
|
||||||
|
|
||||||
|
# tpr_price
|
||||||
|
if self.creating:
|
||||||
|
f.remove_field('tpr_price')
|
||||||
|
else:
|
||||||
|
f.set_readonly('tpr_price')
|
||||||
|
f.set_renderer('tpr_price', self.render_price)
|
||||||
|
|
||||||
|
# tpr_price_ends
|
||||||
|
if self.creating:
|
||||||
|
f.remove_field('tpr_price_ends')
|
||||||
|
else:
|
||||||
|
f.set_readonly('tpr_price_ends')
|
||||||
|
f.set_renderer('tpr_price_ends', self.render_tpr_price_ends)
|
||||||
|
|
||||||
# vendor
|
# vendor
|
||||||
if self.creating:
|
if self.creating:
|
||||||
f.remove_field('vendor')
|
f.remove_field('vendor')
|
||||||
|
@ -1011,6 +1057,22 @@ class ProductView(MasterView):
|
||||||
return ""
|
return ""
|
||||||
return raw_datetime(self.request.rattail_config, value)
|
return raw_datetime(self.request.rattail_config, value)
|
||||||
|
|
||||||
|
def render_sale_price_ends(self, product, field):
|
||||||
|
if not product.sale_price:
|
||||||
|
return
|
||||||
|
ends = product.sale_price.ends
|
||||||
|
if not ends:
|
||||||
|
return
|
||||||
|
return raw_datetime(self.rattail_config, ends)
|
||||||
|
|
||||||
|
def render_tpr_price_ends(self, product, field):
|
||||||
|
if not product.tpr_price:
|
||||||
|
return
|
||||||
|
ends = product.tpr_price.ends
|
||||||
|
if not ends:
|
||||||
|
return
|
||||||
|
return raw_datetime(self.rattail_config, ends)
|
||||||
|
|
||||||
def render_inventory_on_hand(self, product, field):
|
def render_inventory_on_hand(self, product, field):
|
||||||
if not product.inventory:
|
if not product.inventory:
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Reference in a new issue