Fix "edit row" logic for ordering batch

previous logic allowed `colander.null` to be passed to batch handler, which
caused an error.  also it allowed editing "all" fields for the row, which we
really don't need to do, so now we just support the order quantities
This commit is contained in:
Lance Edgar 2020-02-24 13:38:58 -06:00
parent fc830f60e8
commit 2b70ed1407
3 changed files with 55 additions and 4 deletions

View file

@ -922,9 +922,19 @@ class PurchasingBatchView(BatchMasterView):
if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING:
# let handler update data, per given order quantities
data = self.form_deserialized
self.handler.update_row_quantity(row, **data)
# figure out which values need updating
form_data = self.form_deserialized
data = {}
for key in ('cases_ordered', 'units_ordered'):
if key in form_data:
# this is really to convert/avoid colander.null, but the
# handler method also assumes that if we pass a value, it
# will not be None
data[key] = form_data[key] or 0
if data:
# let handler do the actual updating
self.handler.update_row_quantity(row, **data)
else: # *not* ordering mode