diff --git a/tailbone/templates/batch/inventory/desktop_form.mako b/tailbone/templates/batch/inventory/desktop_form.mako
index 22ca68d7..bc64d498 100644
--- a/tailbone/templates/batch/inventory/desktop_form.mako
+++ b/tailbone/templates/batch/inventory/desktop_form.mako
@@ -143,7 +143,7 @@
if (data.product.type2) {
$('#units').focus().select();
} else {
- % if allow_cases:
+ % if allow_cases and prefer_cases:
if ($('#cases').val()) {
$('#cases').focus().select();
} else if ($('#units').val()) {
diff --git a/tailbone/templates/mobile/batch/inventory/view_row.mako b/tailbone/templates/mobile/batch/inventory/view_row.mako
index 8643da1e..bfb06dcf 100644
--- a/tailbone/templates/mobile/batch/inventory/view_row.mako
+++ b/tailbone/templates/mobile/batch/inventory/view_row.mako
@@ -5,19 +5,6 @@
## TODO: this is broken for actual page (header) title
<%def name="title()">${h.link_to("Inventory", url('mobile.batch.inventory'))} » ${h.link_to(batch.id_str, url('mobile.batch.inventory.view', uuid=batch.uuid))} » ${row.upc.pretty()}%def>
-<%
- unit_uom = 'LB' if row.product and row.product.weighed else 'EA'
-
- if row.cases and allow_cases:
- uom = 'CS'
- elif row.units:
- uom = unit_uom
- elif row.case_quantity and allow_cases:
- uom = 'CS'
- else:
- uom = unit_uom
-%>
-
% if instance.product:
diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py
index d1f36c7b..886b078d 100644
--- a/tailbone/views/batch/core.py
+++ b/tailbone/views/batch/core.py
@@ -621,7 +621,7 @@ class BatchMasterView(MasterView):
if self.request.has_perm('{}.create_row'.format(permission_prefix)):
link = tags.link_to("Create a new {}".format(self.get_row_model_title()),
self.get_action_url('create_row', batch))
- return HTML.tag('p', c=link)
+ return HTML.tag('p', c=[link])
def make_batch_row_grid_tools(self, batch):
if self.rows_bulk_deletable and not batch.executed and self.request.has_perm('{}.delete_rows'.format(self.get_permission_prefix())):
diff --git a/tailbone/views/inventory.py b/tailbone/views/inventory.py
index 1414e730..85171330 100644
--- a/tailbone/views/inventory.py
+++ b/tailbone/views/inventory.py
@@ -110,6 +110,9 @@ class InventoryBatchView(BatchMasterView):
# when the batch count mode is "adjust only"
allow_adjustment_cases = True
+ # set to True for the UI to "prefer" case amounts, as opposed to unit
+ prefer_cases = False
+
labels = {
'mode': "Count Mode",
}
@@ -342,6 +345,7 @@ class InventoryBatchView(BatchMasterView):
'form': form,
'dform': form.make_deform_form(),
'allow_cases': self.allow_cases(batch),
+ 'prefer_cases': self.prefer_cases,
})
def allow_cases(self, batch):
@@ -584,6 +588,18 @@ class InventoryBatchView(BatchMasterView):
row = self.get_row_instance()
batch = self.get_parent(row)
form = self.make_mobile_row_form(row)
+
+ allow_cases = self.allow_cases(batch)
+ unit_uom = 'LB' if row.product and row.product.weighed else 'EA'
+ if row.cases and allow_cases:
+ uom = 'CS'
+ elif row.units:
+ uom = unit_uom
+ elif row.case_quantity and allow_cases and self.prefer_cases:
+ uom = 'CS'
+ else:
+ uom = unit_uom
+
context = {
'row': row,
'batch': batch,
@@ -594,7 +610,9 @@ class InventoryBatchView(BatchMasterView):
'parent_url': self.get_action_url('view', batch, mobile=True),
'product_image_url': pod.get_image_url(self.rattail_config, row.upc),
'form': form,
- 'allow_cases': self.allow_cases(batch),
+ 'allow_cases': allow_cases,
+ 'unit_uom': unit_uom,
+ 'uom': uom,
}
if self.request.has_perm('{}.edit_row'.format(self.get_permission_prefix())):
diff --git a/tailbone/views/master.py b/tailbone/views/master.py
index 74a18f05..6a8b70fb 100644
--- a/tailbone/views/master.py
+++ b/tailbone/views/master.py
@@ -1340,7 +1340,7 @@ class MasterView(View):
if self.rows_creatable:
link = tags.link_to("Create a new {}".format(self.get_row_model_title()),
self.get_action_url('create_row', obj))
- return HTML.tag('p', c=link)
+ return HTML.tag('p', c=[link])
def make_row_grid_tools(self, obj):
return self.make_default_row_grid_tools(obj)