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:
parent
c5fef6b954
commit
5b2f4127ea
|
@ -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',
|
||||
|
|
|
@ -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...
|
||||
|
|
Loading…
Reference in a new issue