Tweak display of inventory/label batches to reflect multiple handheld batches

This commit is contained in:
Lance Edgar 2017-06-21 15:36:32 -05:00
parent 1fc3133f8e
commit a63f2e3623
5 changed files with 35 additions and 17 deletions

View file

@ -48,4 +48,4 @@ from .products import (GPCFieldRenderer, ScancodeFieldRenderer,
from .custorders import CustomerOrderFieldRenderer from .custorders import CustomerOrderFieldRenderer
from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer, HandheldBatchesFieldRenderer

View file

@ -31,7 +31,7 @@ import stat
import random import random
import formalchemy as fa import formalchemy as fa
from webhelpers.html import tags from webhelpers.html import tags, HTML
from tailbone.forms.renderers import FileFieldRenderer as BaseFileFieldRenderer from tailbone.forms.renderers import FileFieldRenderer as BaseFileFieldRenderer
@ -86,3 +86,18 @@ class HandheldBatchFieldRenderer(fa.FieldRenderer):
batch.id_str, batch.id_str,
self.request.route_url('batch.handheld.view', uuid=batch.uuid)) self.request.route_url('batch.handheld.view', uuid=batch.uuid))
return '' return ''
class HandheldBatchesFieldRenderer(fa.FieldRenderer):
"""
Renders a list of associated handheld batches, for a given (presumably
inventory or labels) batch.
"""
def render_readonly(self, **kwargs):
items = ''
for handheld in self.raw_value:
text = tags.link_to(handheld.handheld.id_str,
self.request.route_url('batch.handheld.view', uuid=handheld.handheld_uuid))
items += HTML.tag('li', c=text)
return HTML.tag('ul', c=items)

View file

@ -101,7 +101,7 @@ class HandheldBatchView(FileBatchMasterView):
def row_attrs(self, batch, i): def row_attrs(self, batch, i):
attrs = {} attrs = {}
if batch.status_code != batch.STATUS_OK: if batch.status_code is not None and batch.status_code != batch.STATUS_OK:
attrs['class_'] = 'notice' attrs['class_'] = 'notice'
return attrs return attrs
@ -196,10 +196,7 @@ class HandheldBatchView(FileBatchMasterView):
if kwargs['action'] == 'make_inventory_batch': if kwargs['action'] == 'make_inventory_batch':
return self.request.route_url('batch.inventory.view', uuid=result.uuid) return self.request.route_url('batch.inventory.view', uuid=result.uuid)
elif kwargs['action'] == 'make_label_batch': elif kwargs['action'] == 'make_label_batch':
if self.rattail_config.getbool('rattail.batch', 'handheld.legacy_label_batch', default=True): return self.request.route_url('labels.batch.view', uuid=result.uuid)
return self.request.route_url('batch.rows', uuid=result.uuid)
else: # new-style labels batch
return self.request.route_url('labels.batch.view', uuid=result.uuid)
return super(HandheldBatchView, self).get_execute_success_url(batch) return super(HandheldBatchView, self).get_execute_success_url(batch)

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2016 Lance Edgar # Copyright © 2010-2017 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -28,6 +28,8 @@ from __future__ import unicode_literals, absolute_import
from rattail.db import model from rattail.db import model
import formalchemy as fa
from tailbone import forms from tailbone import forms
from tailbone.views.batch import BatchMasterView from tailbone.views.batch import BatchMasterView
@ -58,9 +60,10 @@ class InventoryBatchView(BatchMasterView):
def _preconfigure_fieldset(self, fs): def _preconfigure_fieldset(self, fs):
super(InventoryBatchView, self)._preconfigure_fieldset(fs) super(InventoryBatchView, self)._preconfigure_fieldset(fs)
fs.handheld_batch.set(renderer=forms.renderers.HandheldBatchFieldRenderer, readonly=True)
fs.mode.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.INVENTORY_MODE), fs.mode.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.INVENTORY_MODE),
label="Count Mode") label="Count Mode")
fs.append(fa.Field('handheld_batches', renderer=forms.renderers.HandheldBatchesFieldRenderer, readonly=True,
value=lambda b: b._handhelds))
def configure_fieldset(self, fs): def configure_fieldset(self, fs):
fs.configure( fs.configure(
@ -68,7 +71,7 @@ class InventoryBatchView(BatchMasterView):
fs.id, fs.id,
fs.created, fs.created,
fs.created_by, fs.created_by,
fs.handheld_batch, fs.handheld_batches,
fs.mode, fs.mode,
fs.executed, fs.executed,
fs.executed_by, fs.executed_by,

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2016 Lance Edgar # Copyright © 2010-2017 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -28,6 +28,8 @@ from __future__ import unicode_literals, absolute_import
from rattail.db import model from rattail.db import model
import formalchemy as fa
from tailbone import forms from tailbone import forms
from tailbone.views.batch import BatchMasterView from tailbone.views.batch import BatchMasterView
@ -49,7 +51,8 @@ class LabelBatchView(BatchMasterView):
def _preconfigure_fieldset(self, fs): def _preconfigure_fieldset(self, fs):
super(LabelBatchView, self)._preconfigure_fieldset(fs) super(LabelBatchView, self)._preconfigure_fieldset(fs)
fs.handheld_batch.set(renderer=forms.renderers.HandheldBatchFieldRenderer, readonly=True) fs.append(fa.Field('handheld_batches', renderer=forms.renderers.HandheldBatchesFieldRenderer, readonly=True,
value=lambda b: b._handhelds))
def configure_fieldset(self, fs): def configure_fieldset(self, fs):
fs.configure( fs.configure(
@ -57,13 +60,13 @@ class LabelBatchView(BatchMasterView):
fs.id, fs.id,
fs.created, fs.created,
fs.created_by, fs.created_by,
fs.handheld_batch, fs.handheld_batches,
fs.executed, fs.executed,
fs.executed_by, fs.executed_by,
]) ])
batch = fs.model batch = fs.model
if self.viewing and not batch.handheld_batch: if self.viewing and not batch._handhelds:
del fs.handheld_batch del fs.handheld_batches
def _preconfigure_row_grid(self, g): def _preconfigure_row_grid(self, g):
super(LabelBatchView, self)._preconfigure_row_grid(g) super(LabelBatchView, self)._preconfigure_row_grid(g)