Refactor inventory batch desktop lookup, to allow for Type 2 UPC logic

for now though, such logic must be provided by custom app
This commit is contained in:
Lance Edgar 2018-03-21 11:30:14 -05:00
parent 42982a69ea
commit e9322628cb
2 changed files with 27 additions and 15 deletions

View file

@ -91,6 +91,9 @@
$('#description').val(data.product.description);
$('#size').val(data.product.size);
$('#case_quantity').val(data.product.case_quantity);
if (data.product.type2) {
$('#units').val(data.product.units);
}
$('#product-info p').text(data.product.full_description);
$('#product-info img').attr('src', data.product.image_url).show();
@ -102,7 +105,11 @@
$('.field-wrapper.cases input').prop('disabled', false);
$('.field-wrapper.units input').prop('disabled', false);
$('.buttons button').button('enable');
if (data.product.type2) {
$('#units').focus().select();
} else {
$('#cases').focus().select();
}
// TODO: this is maybe useful if "new products" may be added via inventory batch
// } else if (data.upc) {

View file

@ -334,6 +334,18 @@ class InventoryBatchView(BatchMasterView):
product = api.get_product_by_upc(self.Session(), provided)
if not product:
product = api.get_product_by_upc(self.Session(), checked)
data = self.product_info(product)
result = {'product': data or None, 'upc_raw': upc, 'upc': None}
if not data and upc:
upc = GPC(upc)
result['upc'] = six.text_type(upc)
result['upc_pretty'] = upc.pretty()
result['image_url'] = pod.get_image_url(self.rattail_config, upc)
return result
def product_info(self, product):
data = {}
if product and (not product.deleted or self.request.has_perm('products.view_deleted')):
data['uuid'] = product.uuid
data['upc'] = six.text_type(product.upc)
@ -345,14 +357,7 @@ class InventoryBatchView(BatchMasterView):
data['case_quantity'] = 1 # default
data['cost_found'] = False
data['image_url'] = pod.get_image_url(self.rattail_config, product.upc)
result = {'product': data or None, 'upc': None}
if not data and upc:
upc = GPC(upc)
result['upc'] = unicode(upc)
result['upc_pretty'] = upc.pretty()
result['image_url'] = pod.get_image_url(self.rattail_config, upc)
return result
return data
def configure_mobile_form(self, f):
super(InventoryBatchView, self).configure_mobile_form(f)
@ -608,7 +613,7 @@ class DesktopForm(colander.Schema):
description = colander.SchemaNode(colander.String())
size = colander.SchemaNode(colander.String())
size = colander.SchemaNode(colander.String(), missing=colander.null)
case_quantity = colander.SchemaNode(colander.Decimal())