From 11a0d852868a233ea11265c76ac160122a2cdca3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 9 Feb 2017 18:58:00 -0600 Subject: [PATCH] Fix bug when first entry is empty for product on ordering form --- tailbone/views/purchases/batch.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tailbone/views/purchases/batch.py b/tailbone/views/purchases/batch.py index 50f7fcf2..33f1a4ee 100644 --- a/tailbone/views/purchases/batch.py +++ b/tailbone/views/purchases/batch.py @@ -657,6 +657,7 @@ class PurchaseBatchView(BatchMasterView): if not product: return {'error': "Product not found"} + row = None rows = [row for row in batch.data_rows if row.product_uuid == uuid] if rows: assert len(rows) == 1 @@ -681,10 +682,10 @@ class PurchaseBatchView(BatchMasterView): self.handler.refresh_row(row) return { - 'row_cases_ordered': '' if row.removed else int(row.cases_ordered or 0), - 'row_units_ordered': '' if row.removed else int(row.units_ordered or 0), - 'row_po_total': '' if row.removed else '${:0,.2f}'.format(row.po_total), - 'batch_po_total': '${:0,.2f}'.format(batch.po_total), + 'row_cases_ordered': '' if not row or row.removed else int(row.cases_ordered or 0), + 'row_units_ordered': '' if not row or row.removed else int(row.units_ordered or 0), + 'row_po_total': '' if not row or row.removed else '${:0,.2f}'.format(row.po_total), + 'batch_po_total': '${:0,.2f}'.format(batch.po_total or 0), } def attach_credit(self, row, credit_type, cases, units, expiration_date=None, discarded=None, mispick_product=None):