Fix bug when first entry is empty for product on ordering form
This commit is contained in:
parent
6e7cad36b2
commit
11a0d85286
|
@ -657,6 +657,7 @@ class PurchaseBatchView(BatchMasterView):
|
||||||
if not product:
|
if not product:
|
||||||
return {'error': "Product not found"}
|
return {'error': "Product not found"}
|
||||||
|
|
||||||
|
row = None
|
||||||
rows = [row for row in batch.data_rows if row.product_uuid == uuid]
|
rows = [row for row in batch.data_rows if row.product_uuid == uuid]
|
||||||
if rows:
|
if rows:
|
||||||
assert len(rows) == 1
|
assert len(rows) == 1
|
||||||
|
@ -681,10 +682,10 @@ class PurchaseBatchView(BatchMasterView):
|
||||||
self.handler.refresh_row(row)
|
self.handler.refresh_row(row)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'row_cases_ordered': '' if row.removed else int(row.cases_ordered or 0),
|
'row_cases_ordered': '' if not row or row.removed else int(row.cases_ordered or 0),
|
||||||
'row_units_ordered': '' if row.removed else int(row.units_ordered or 0),
|
'row_units_ordered': '' if not row or row.removed else int(row.units_ordered or 0),
|
||||||
'row_po_total': '' if row.removed else '${:0,.2f}'.format(row.po_total),
|
'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),
|
'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):
|
def attach_credit(self, row, credit_type, cases, units, expiration_date=None, discarded=None, mispick_product=None):
|
||||||
|
|
Loading…
Reference in a new issue