Make handler responsible for locating product for inventory batch

This commit is contained in:
Lance Edgar 2020-03-29 14:49:33 -05:00
parent 0e7835e2d9
commit 71a9010579

View file

@ -33,7 +33,7 @@ import logging
import six import six
from rattail import pod 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.db.util import make_full_description
from rattail.time import localtime from rattail.time import localtime
from rattail.gpc import GPC from rattail.gpc import GPC
@ -375,25 +375,13 @@ class InventoryBatchView(BatchMasterView):
def find_row_for_product(self, batch, product): def find_row_for_product(self, batch, product):
return self.handler.find_row_for_product(self.Session(), batch, product) return self.handler.find_row_for_product(self.Session(), batch, product)
# TODO: deprecate / remove (?)
def find_product(self, entry): def find_product(self, entry):
upc = re.sub(r'\D', '', entry.strip()) lookup_by_code = self.rattail_config.getbool(
if upc: 'tailbone', 'inventory.lookup_by_code', default=False)
# first try to locate existing batch row by UPC match return self.handler.locate_product_for_entry(
provided = GPC(upc, calc_check_digit=False) self.Session(), entry, lookup_by_code=lookup_by_code)
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
def product_info(self, product): def product_info(self, product):
data = {} data = {}