Use "quick entry" logic from batch handler, for mobile inventory

pretty sure desktop version still needs cleanup, but later...
This commit is contained in:
Lance Edgar 2020-03-29 15:19:22 -05:00
parent 71a9010579
commit e9fc9ccbf7

View file

@ -452,45 +452,15 @@ class InventoryBatchView(BatchMasterView):
""" """
Add a row to the batch for the given UPC, if applicable. Add a row to the batch for the given UPC, if applicable.
""" """
type2 = self.find_type2_product(entry) row = self.handler.quick_entry(self.Session(), batch, entry)
if type2: if row:
product, price = type2
else:
product = self.find_product(entry)
if product:
force_unit_item = self.rattail_config.getbool( if row.product and getattr(row.product, '__forced_unit_item__', False):
'tailbone', 'inventory.force_unit_item', default=False)
if force_unit_item and product.is_pack_item():
product = product.unit
self.request.session.flash("You scanned a pack item, but must count the units instead.", 'error') self.request.session.flash("You scanned a pack item, but must count the units instead.", 'error')
aggregate = self.should_aggregate_products(batch) if warn_if_present and getattr(row, '__existing_reused__', False):
if aggregate:
row = self.find_row_for_product(batch, product)
if row:
if warn_if_present:
self.request.session.flash("Product already exists in batch; please confirm counts", 'error') self.request.session.flash("Product already exists in batch; please confirm counts", 'error')
return row
row = model.InventoryBatchRow()
row.product = product
row.upc = product.upc
self.handler.capture_current_units(row)
if type2 and not aggregate:
if price is None:
row.units = 1
else:
row.units = (price / product.regular_price.price).quantize(decimal.Decimal('0.01'))
self.handler.add_row(batch, row)
return row
elif self.handler.unknown_product_creates_row:
row = model.InventoryBatchRow()
row.upc = GPC(upc, calc_check_digit=False) # TODO: why not calc check digit?
row.description = "(unknown product)"
self.handler.capture_current_units(row)
self.handler.add_row(batch, row)
return row return row
def template_kwargs_view_row(self, **kwargs): def template_kwargs_view_row(self, **kwargs):