From 5b2f4127ea68cc715d8fd23d7a77ca3aec8aefc3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 19 Sep 2018 11:00:10 -0500 Subject: [PATCH] Fix bug when editing truck dump child batch row quantities sometimes we need to "add" to an existing claim which has qty None --- tailbone/views/purchasing/batch.py | 3 +++ tailbone/views/purchasing/receiving.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tailbone/views/purchasing/batch.py b/tailbone/views/purchasing/batch.py index 8941de1c..746ae4d3 100644 --- a/tailbone/views/purchasing/batch.py +++ b/tailbone/views/purchasing/batch.py @@ -662,6 +662,9 @@ class PurchasingBatchView(BatchMasterView): f.set_type('invoice_unit_cost', 'currency') f.set_type('invoice_total', 'currency') + # upc + f.set_type('upc', 'gpc') + if self.creating: f.remove_fields( 'upc', diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index 88acc16c..b61c53af 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -775,6 +775,9 @@ class ReceivingBatchView(PurchasingBatchView): parent_rows = [row for row in batch.truck_dump_batch.active_rows() if row.product_uuid == old_row.product_uuid] + # NOTE: "confirmed" are the proper amounts which exist in the + # parent batch. "claimed" are the amounts claimed by this row. + # get existing "confirmed" and "claimed" amounts for all # (possibly related) truck dump parent rows confirmed = {} @@ -882,7 +885,7 @@ class ReceivingBatchView(PurchasingBatchView): # next we'd prefer to add to an existing claim, of any kind elif row.truck_dump_claims: claim = row.truck_dump_claims[0] - setattr(claim, key, getattr(claim, key) + amount) + setattr(claim, key, (getattr(claim, key) or 0) + amount) else: # otherwise we must create a new claim...