diff --git a/tailbone/forms/renderers/__init__.py b/tailbone/forms/renderers/__init__.py index 91f1c247..127f47b5 100644 --- a/tailbone/forms/renderers/__init__.py +++ b/tailbone/forms/renderers/__init__.py @@ -48,4 +48,4 @@ from .products import (GPCFieldRenderer, ScancodeFieldRenderer, from .custorders import CustomerOrderFieldRenderer -from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer +from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer, HandheldBatchesFieldRenderer diff --git a/tailbone/forms/renderers/batch.py b/tailbone/forms/renderers/batch.py index 2b6e1168..a8fc0a1a 100644 --- a/tailbone/forms/renderers/batch.py +++ b/tailbone/forms/renderers/batch.py @@ -31,7 +31,7 @@ import stat import random import formalchemy as fa -from webhelpers.html import tags +from webhelpers.html import tags, HTML from tailbone.forms.renderers import FileFieldRenderer as BaseFileFieldRenderer @@ -86,3 +86,18 @@ class HandheldBatchFieldRenderer(fa.FieldRenderer): batch.id_str, self.request.route_url('batch.handheld.view', uuid=batch.uuid)) 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) diff --git a/tailbone/views/handheld.py b/tailbone/views/handheld.py index 1ad2648b..b4c0b297 100644 --- a/tailbone/views/handheld.py +++ b/tailbone/views/handheld.py @@ -101,7 +101,7 @@ class HandheldBatchView(FileBatchMasterView): def row_attrs(self, batch, i): 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' return attrs @@ -196,10 +196,7 @@ class HandheldBatchView(FileBatchMasterView): if kwargs['action'] == 'make_inventory_batch': return self.request.route_url('batch.inventory.view', uuid=result.uuid) elif kwargs['action'] == 'make_label_batch': - if self.rattail_config.getbool('rattail.batch', 'handheld.legacy_label_batch', default=True): - 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 self.request.route_url('labels.batch.view', uuid=result.uuid) return super(HandheldBatchView, self).get_execute_success_url(batch) diff --git a/tailbone/views/inventory.py b/tailbone/views/inventory.py index e3aa9abe..a376a459 100644 --- a/tailbone/views/inventory.py +++ b/tailbone/views/inventory.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2016 Lance Edgar +# Copyright © 2010-2017 Lance Edgar # # This file is part of Rattail. # @@ -28,6 +28,8 @@ from __future__ import unicode_literals, absolute_import from rattail.db import model +import formalchemy as fa + from tailbone import forms from tailbone.views.batch import BatchMasterView @@ -58,9 +60,10 @@ class InventoryBatchView(BatchMasterView): def _preconfigure_fieldset(self, 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), 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): fs.configure( @@ -68,7 +71,7 @@ class InventoryBatchView(BatchMasterView): fs.id, fs.created, fs.created_by, - fs.handheld_batch, + fs.handheld_batches, fs.mode, fs.executed, fs.executed_by, diff --git a/tailbone/views/labels/batch.py b/tailbone/views/labels/batch.py index 10fbbf41..6bab77d1 100644 --- a/tailbone/views/labels/batch.py +++ b/tailbone/views/labels/batch.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; -*- ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2016 Lance Edgar +# Copyright © 2010-2017 Lance Edgar # # This file is part of Rattail. # @@ -28,6 +28,8 @@ from __future__ import unicode_literals, absolute_import from rattail.db import model +import formalchemy as fa + from tailbone import forms from tailbone.views.batch import BatchMasterView @@ -49,7 +51,8 @@ class LabelBatchView(BatchMasterView): def _preconfigure_fieldset(self, 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): fs.configure( @@ -57,13 +60,13 @@ class LabelBatchView(BatchMasterView): fs.id, fs.created, fs.created_by, - fs.handheld_batch, + fs.handheld_batches, fs.executed, fs.executed_by, ]) batch = fs.model - if self.viewing and not batch.handheld_batch: - del fs.handheld_batch + if self.viewing and not batch._handhelds: + del fs.handheld_batches def _preconfigure_row_grid(self, g): super(LabelBatchView, self)._preconfigure_row_grid(g)