Cleanup refresh logic a bit, for vendor invoice batches
This commit is contained in:
parent
d96d22ab68
commit
76da7e7193
|
@ -108,29 +108,29 @@ class VendorInvoiceHandler(BatchHandler):
|
||||||
"""
|
"""
|
||||||
Attempt to locate the product for the row, based on UPC etc.
|
Attempt to locate the product for the row, based on UPC etc.
|
||||||
"""
|
"""
|
||||||
|
session = orm.object_session(row)
|
||||||
|
|
||||||
|
if row.upc:
|
||||||
|
product = self.find_product_by_upc(session, row.upc)
|
||||||
|
if product:
|
||||||
|
return product
|
||||||
|
|
||||||
|
if row.vendor_code:
|
||||||
|
product = self.find_product_by_vendor_code(session, row.vendor_code)
|
||||||
|
if product:
|
||||||
|
return product
|
||||||
|
|
||||||
|
def find_product_by_upc(self, session, upc):
|
||||||
if hasattr(self, 'products'):
|
if hasattr(self, 'products'):
|
||||||
|
return self.products['upc'].get(upc)
|
||||||
|
else:
|
||||||
|
return api.get_product_by_upc(session, upc)
|
||||||
|
|
||||||
if row.upc:
|
def find_product_by_vendor_code(self, session, code):
|
||||||
product = self.products['upc'].get(row.upc)
|
if hasattr(self, 'products'):
|
||||||
if product:
|
return self.products['vendor_code'].get(code)
|
||||||
return product
|
else:
|
||||||
|
return api.get_product_by_upc(session, code, self.vendor)
|
||||||
if row.vendor_code:
|
|
||||||
product = self.products['vendor_code'].get(row.vendor_code)
|
|
||||||
if product:
|
|
||||||
return product
|
|
||||||
|
|
||||||
else: # no cache, must query
|
|
||||||
|
|
||||||
session = orm.object_session(row)
|
|
||||||
|
|
||||||
if row.upc:
|
|
||||||
product = api.get_product_by_upc(session, row.upc)
|
|
||||||
if product:
|
|
||||||
return product
|
|
||||||
|
|
||||||
if row.vendor_code:
|
|
||||||
product = api.get_product_by_vendor_code(session, row.vendor_code, self.vendor)
|
|
||||||
|
|
||||||
def refresh_row(self, row):
|
def refresh_row(self, row):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue