Make inventory batch handler responsible for finding row for product

This commit is contained in:
Lance Edgar 2020-03-29 14:41:16 -05:00
parent 069eac1cf6
commit 0e7835e2d9

View file

@ -371,17 +371,9 @@ class InventoryBatchView(BatchMasterView):
return result
# TODO: deprecate / remove
def find_row_for_product(self, batch, product):
rows = self.Session.query(model.InventoryBatchRow)\
.filter(model.InventoryBatchRow.batch == batch)\
.filter(model.InventoryBatchRow.product == product)\
.filter(model.InventoryBatchRow.removed == False)\
.all()
if rows:
if len(rows) > 1:
log.error("inventory batch %s should aggregate products, but has %s rows for: %s",
batch.id_str, len(rows), product)
return rows[0]
return self.handler.find_row_for_product(self.Session(), batch, product)
def find_product(self, entry):
upc = re.sub(r'\D', '', entry.strip())