diff --git a/tailbone/views/purchasing/ordering.py b/tailbone/views/purchasing/ordering.py index 06d7eb6b..9437b40d 100644 --- a/tailbone/views/purchasing/ordering.py +++ b/tailbone/views/purchasing/ordering.py @@ -264,18 +264,21 @@ class OrderingBatchView(PurchasingBatchView): row.removed = False batch.rowcount += 1 self.handler.refresh_row(row) + if row.po_unit_cost: + row.po_total = row.po_unit_cost * self.handler.get_units_ordered(row) + batch.po_total = (batch.po_total or 0) + row.po_total else: row.removed = True elif cases_ordered or units_ordered: row = model.PurchaseBatchRow() - row.sequence = max([0] + [r.sequence for r in batch.data_rows]) + 1 row.product = product - batch.data_rows.append(row) row.cases_ordered = cases_ordered or None row.units_ordered = units_ordered or None - self.handler.refresh_row(row) - batch.rowcount = (batch.rowcount or 0) + 1 + self.handler.add_row(batch, row) + if row.po_unit_cost: + row.po_total = row.po_unit_cost * self.handler.get_units_ordered(row) + batch.po_total = (batch.po_total or 0) + row.po_total return { 'row_cases_ordered': '' if not row or row.removed else int(row.cases_ordered or 0),