Clean up some inventory batch UI logic; prefer units by default
This commit is contained in:
parent
d61d9cc574
commit
c7496d7018
|
@ -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()) {
|
||||
|
|
|
@ -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
|
||||
%>
|
||||
|
||||
<div class="ui-grid-a">
|
||||
<div class="ui-block-a">
|
||||
% if instance.product:
|
||||
|
|
|
@ -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())):
|
||||
|
|
|
@ -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())):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue