Use "quick entry" logic from batch handler, for mobile inventory
pretty sure desktop version still needs cleanup, but later...
This commit is contained in:
parent
71a9010579
commit
e9fc9ccbf7
|
@ -452,45 +452,15 @@ class InventoryBatchView(BatchMasterView):
|
|||
"""
|
||||
Add a row to the batch for the given UPC, if applicable.
|
||||
"""
|
||||
type2 = self.find_type2_product(entry)
|
||||
if type2:
|
||||
product, price = type2
|
||||
else:
|
||||
product = self.find_product(entry)
|
||||
if product:
|
||||
row = self.handler.quick_entry(self.Session(), batch, entry)
|
||||
if row:
|
||||
|
||||
force_unit_item = self.rattail_config.getbool(
|
||||
'tailbone', 'inventory.force_unit_item', default=False)
|
||||
if force_unit_item and product.is_pack_item():
|
||||
product = product.unit
|
||||
if row.product and getattr(row.product, '__forced_unit_item__', False):
|
||||
self.request.session.flash("You scanned a pack item, but must count the units instead.", 'error')
|
||||
|
||||
aggregate = self.should_aggregate_products(batch)
|
||||
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')
|
||||
return row
|
||||
if warn_if_present and getattr(row, '__existing_reused__', False):
|
||||
self.request.session.flash("Product already exists in batch; please confirm counts", 'error')
|
||||
|
||||
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
|
||||
|
||||
def template_kwargs_view_row(self, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue