Update calculated PO totals for purchasing batch, when editing row

This commit is contained in:
Lance Edgar 2019-06-08 13:16:57 -05:00
parent 643d29ba57
commit d7e19865de

View file

@ -896,14 +896,23 @@ class PurchasingBatchView(BatchMasterView):
batch = row.batch
# first undo any totals previously in effect for the row
if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING and row.po_total:
batch.po_total -= row.po_total
if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING and row.po_total_calculated:
batch.po_total_calculated -= row.po_total_calculated
elif batch.mode == self.enum.PURCHASE_BATCH_MODE_RECEIVING and row.invoice_total:
# TODO: pretty sure this should update the `_calculated` value instead?
# TODO: also, should update the value again after the super() call
batch.invoice_total -= row.invoice_total
row = super(PurchasingBatchView, self).save_edit_row_form(form)
# TODO: is this needed?
# self.handler.refresh_row(row)
# now apply new totals based on current row quantity
if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING and row.po_unit_cost is not None:
row.po_total_calculated = row.po_unit_cost * self.handler.get_units_ordered(row)
batch.po_total_calculated += row.po_total_calculated
return row
# def redirect_after_create_row(self, row):