Avoid making discounts data if missing field, for trainwreck item view

This commit is contained in:
Lance Edgar 2022-03-01 13:01:59 -06:00
parent 59a9d2cf86
commit 031d97aea3

View file

@ -268,17 +268,19 @@ class TransactionView(MasterView):
def template_kwargs_view_row(self, **kwargs): def template_kwargs_view_row(self, **kwargs):
use_buefy = self.get_use_buefy() use_buefy = self.get_use_buefy()
if use_buefy: if use_buefy:
form = kwargs['form']
if 'discounts' in form:
app = self.get_rattail_app() app = self.get_rattail_app()
item = kwargs['instance'] item = kwargs['instance']
discounts_data = [] discounts_data = []
for discount in item.discounts: for discount in item.discounts:
discounts_data.append({ discounts_data.append({
'discount_type': discount.discount_type, 'discount_type': discount.discount_type,
'description': discount.description, 'description': discount.description,
'amount': app.render_currency(discount.amount), 'amount': app.render_currency(discount.amount),
}) })
kwargs['discounts_data'] = discounts_data kwargs['discounts_data'] = discounts_data
return kwargs return kwargs