Clean up some inventory batch UI logic; prefer units by default

This commit is contained in:
Lance Edgar 2018-12-18 15:13:01 -06:00
parent d61d9cc574
commit c7496d7018
5 changed files with 22 additions and 17 deletions

View file

@ -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())):

View file

@ -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())):

View file

@ -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)