diff --git a/tailbone/views/batch/inventory.py b/tailbone/views/batch/inventory.py index 91577277..0fcb9e87 100644 --- a/tailbone/views/batch/inventory.py +++ b/tailbone/views/batch/inventory.py @@ -33,7 +33,7 @@ import logging import six from rattail import pod -from rattail.db import model, api +from rattail.db import model from rattail.db.util import make_full_description from rattail.time import localtime from rattail.gpc import GPC @@ -375,25 +375,13 @@ class InventoryBatchView(BatchMasterView): def find_row_for_product(self, batch, product): return self.handler.find_row_for_product(self.Session(), batch, product) + # TODO: deprecate / remove (?) def find_product(self, entry): - upc = re.sub(r'\D', '', entry.strip()) - if upc: + lookup_by_code = self.rattail_config.getbool( + 'tailbone', 'inventory.lookup_by_code', default=False) - # first try to locate existing batch row by UPC match - provided = GPC(upc, calc_check_digit=False) - checked = GPC(upc, calc_check_digit='upc') - product = api.get_product_by_upc(self.Session(), provided) - if product: - return product - product = api.get_product_by_upc(self.Session(), checked) - if product: - return product - - # maybe try to locate product by alternate code - if self.rattail_config.getbool('tailbone', 'inventory.lookup_by_code', default=False): - product = api.get_product_by_code(self.Session(), entry) - if product: - return product + return self.handler.locate_product_for_entry( + self.Session(), entry, lookup_by_code=lookup_by_code) def product_info(self, product): data = {}