diff --git a/tailbone/templates/batch/inventory/desktop_form.mako b/tailbone/templates/batch/inventory/desktop_form.mako index a1adcf4e..828ab33a 100644 --- a/tailbone/templates/batch/inventory/desktop_form.mako +++ b/tailbone/templates/batch/inventory/desktop_form.mako @@ -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'); - $('#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 // } else if (data.upc) { diff --git a/tailbone/views/inventory.py b/tailbone/views/inventory.py index 3b785612..bff6c048 100644 --- a/tailbone/views/inventory.py +++ b/tailbone/views/inventory.py @@ -334,26 +334,31 @@ class InventoryBatchView(BatchMasterView): product = api.get_product_by_upc(self.Session(), provided) if not product: product = api.get_product_by_upc(self.Session(), checked) - 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) + data = self.product_info(product) - result = {'product': data or None, 'upc': None} + result = {'product': data or None, 'upc_raw': upc, 'upc': None} if not data and upc: upc = GPC(upc) - result['upc'] = unicode(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) + 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): super(InventoryBatchView, self).configure_mobile_form(f) batch = f.model_instance @@ -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())