Add option for preventing new inventory batch rows for unknown products

This commit is contained in:
Lance Edgar 2018-01-17 14:55:17 -06:00
parent dd7c2a0763
commit a542cd70da

View file

@ -221,6 +221,9 @@ class InventoryBatchView(BatchMasterView):
else:
del fs.complete
# TODO: document this, maybe move it etc.
unknown_product_creates_row = True
# TODO: this view can create new rows, with only a GET query. that should
# probably be changed to require POST; for now we just require the "create
# batch row" perm and call it good..
@ -243,6 +246,7 @@ class InventoryBatchView(BatchMasterView):
product = api.get_product_by_upc(self.Session(), provided)
if not product:
product = api.get_product_by_upc(self.Session(), checked)
if product or self.unknown_product_creates_row:
row = model.InventoryBatchRow()
if product:
row.product = product
@ -252,6 +256,10 @@ class InventoryBatchView(BatchMasterView):
row.description = "(unknown product)"
self.handler.add_row(batch, row)
else:
self.request.session.flash("Product not found: {}".format(upc), 'error')
return self.redirect(self.get_action_url('view', batch, mobile=True))
else:
self.request.session.flash("UPC has too many digits ({}): {}".format(len(upc), upc), 'error')
return self.redirect(self.get_action_url('view', batch, mobile=True))