Fix bug when editing truck dump child batch row quantities

sometimes we need to "add" to an existing claim which has qty None
This commit is contained in:
Lance Edgar 2018-09-19 11:00:10 -05:00
parent c5fef6b954
commit 5b2f4127ea
2 changed files with 7 additions and 1 deletions

View file

@ -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',

View file

@ -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...