Fix bug when first entry is empty for product on ordering form

This commit is contained in:
Lance Edgar 2017-02-09 18:58:00 -06:00
parent 6e7cad36b2
commit 11a0d85286

View file

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