Add ProductsHandler.get_image_url()
etc.
plus misc. tweaks for sake of new "scanning" feature for ordering batches
This commit is contained in:
parent
ff576a3e8e
commit
26928bc0d1
|
@ -26,6 +26,7 @@ Handler for "purchasing" batches
|
|||
|
||||
from __future__ import unicode_literals, absolute_import, division
|
||||
|
||||
import decimal
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
@ -1820,11 +1821,15 @@ class PurchaseBatchHandler(BatchHandler):
|
|||
if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING:
|
||||
cases_ordered = kwargs.get('cases_ordered')
|
||||
if cases_ordered is not None:
|
||||
if isinstance(cases_ordered, six.string_types):
|
||||
cases_ordered = decimal.Decimal(cases_ordered or '0')
|
||||
cases_diff = cases_ordered - (row.cases_ordered or 0)
|
||||
if cases_diff:
|
||||
self.order_row(row, cases=cases_diff)
|
||||
units_ordered = kwargs.get('units_ordered')
|
||||
if units_ordered is not None:
|
||||
if isinstance(units_ordered, six.string_types):
|
||||
units_ordered = decimal.Decimal(units_ordered or '0')
|
||||
units_diff = units_ordered - (row.units_ordered or 0)
|
||||
if units_diff:
|
||||
self.order_row(row, units=units_diff)
|
||||
|
|
|
@ -569,12 +569,12 @@ class RattailConfig(object):
|
|||
spec = self.require('rattail.trainwreck', 'model', usedb=False)
|
||||
return import_module_path(spec)
|
||||
|
||||
def product_key(self):
|
||||
def product_key(self, default='upc'):
|
||||
"""
|
||||
Returns the name of the attribute which should be treated as the
|
||||
canonical product key field, e.g. 'upc' or 'item_id' etc.
|
||||
"""
|
||||
return self.get('rattail', 'product.key', default='upc')
|
||||
return self.get('rattail', 'product.key', default=default) or default
|
||||
|
||||
def product_key_title(self, key=None):
|
||||
"""
|
||||
|
|
|
@ -29,6 +29,7 @@ from __future__ import unicode_literals, absolute_import
|
|||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from rattail import pod
|
||||
from rattail.util import load_object
|
||||
from rattail.app import GenericHandler
|
||||
|
||||
|
@ -42,6 +43,22 @@ class ProductsHandler(GenericHandler):
|
|||
particular product can be deleted, etc.
|
||||
"""
|
||||
|
||||
def get_image_url(self, upc=None, product=None, **kwargs):
|
||||
"""
|
||||
Return the preferred image URL for the given UPC or product.
|
||||
"""
|
||||
if product and product.upc:
|
||||
upc = product.upc
|
||||
if upc:
|
||||
return self.get_pod_image_url(upc)
|
||||
|
||||
def get_pod_image_url(self, upc, **kwargs):
|
||||
"""
|
||||
Return the POD image URL for the given UPC.
|
||||
"""
|
||||
if upc:
|
||||
return pod.get_image_url(self.config, upc)
|
||||
|
||||
def get_uom_sil_codes(self, session, uppercase=False, **kwargs):
|
||||
"""
|
||||
This should return a dict, keys of which are UOM abbreviation strings,
|
||||
|
|
Loading…
Reference in a new issue