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:
parent
42982a69ea
commit
e9322628cb
|
@ -91,6 +91,9 @@
|
||||||
$('#description').val(data.product.description);
|
$('#description').val(data.product.description);
|
||||||
$('#size').val(data.product.size);
|
$('#size').val(data.product.size);
|
||||||
$('#case_quantity').val(data.product.case_quantity);
|
$('#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 p').text(data.product.full_description);
|
||||||
$('#product-info img').attr('src', data.product.image_url).show();
|
$('#product-info img').attr('src', data.product.image_url).show();
|
||||||
|
@ -102,7 +105,11 @@
|
||||||
$('.field-wrapper.cases input').prop('disabled', false);
|
$('.field-wrapper.cases input').prop('disabled', false);
|
||||||
$('.field-wrapper.units input').prop('disabled', false);
|
$('.field-wrapper.units input').prop('disabled', false);
|
||||||
$('.buttons button').button('enable');
|
$('.buttons button').button('enable');
|
||||||
$('#cases').focus().select();
|
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
|
// TODO: this is maybe useful if "new products" may be added via inventory batch
|
||||||
// } else if (data.upc) {
|
// } else if (data.upc) {
|
||||||
|
|
|
@ -334,26 +334,31 @@ class InventoryBatchView(BatchMasterView):
|
||||||
product = api.get_product_by_upc(self.Session(), provided)
|
product = api.get_product_by_upc(self.Session(), provided)
|
||||||
if not product:
|
if not product:
|
||||||
product = api.get_product_by_upc(self.Session(), checked)
|
product = api.get_product_by_upc(self.Session(), checked)
|
||||||
if product and (not product.deleted or self.request.has_perm('products.view_deleted')):
|
data = self.product_info(product)
|
||||||
data['uuid'] = product.uuid
|
|
||||||
data['upc'] = six.text_type(product.upc)
|
|
||||||
data['upc_pretty'] = product.upc.pretty()
|
|
||||||
data['full_description'] = product.full_description
|
|
||||||
data['brand_name'] = six.text_type(product.brand or '')
|
|
||||||
data['description'] = product.description
|
|
||||||
data['size'] = product.size
|
|
||||||
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}
|
result = {'product': data or None, 'upc_raw': upc, 'upc': None}
|
||||||
if not data and upc:
|
if not data and upc:
|
||||||
upc = GPC(upc)
|
upc = GPC(upc)
|
||||||
result['upc'] = unicode(upc)
|
result['upc'] = six.text_type(upc)
|
||||||
result['upc_pretty'] = upc.pretty()
|
result['upc_pretty'] = upc.pretty()
|
||||||
result['image_url'] = pod.get_image_url(self.rattail_config, upc)
|
result['image_url'] = pod.get_image_url(self.rattail_config, upc)
|
||||||
return result
|
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)
|
||||||
|
data['upc_pretty'] = product.upc.pretty()
|
||||||
|
data['full_description'] = product.full_description
|
||||||
|
data['brand_name'] = six.text_type(product.brand or '')
|
||||||
|
data['description'] = product.description
|
||||||
|
data['size'] = product.size
|
||||||
|
data['case_quantity'] = 1 # default
|
||||||
|
data['cost_found'] = False
|
||||||
|
data['image_url'] = pod.get_image_url(self.rattail_config, product.upc)
|
||||||
|
return data
|
||||||
|
|
||||||
def configure_mobile_form(self, f):
|
def configure_mobile_form(self, f):
|
||||||
super(InventoryBatchView, self).configure_mobile_form(f)
|
super(InventoryBatchView, self).configure_mobile_form(f)
|
||||||
batch = f.model_instance
|
batch = f.model_instance
|
||||||
|
@ -608,7 +613,7 @@ class DesktopForm(colander.Schema):
|
||||||
|
|
||||||
description = colander.SchemaNode(colander.String())
|
description = colander.SchemaNode(colander.String())
|
||||||
|
|
||||||
size = colander.SchemaNode(colander.String())
|
size = colander.SchemaNode(colander.String(), missing=colander.null)
|
||||||
|
|
||||||
case_quantity = colander.SchemaNode(colander.Decimal())
|
case_quantity = colander.SchemaNode(colander.Decimal())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue