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):