Tweak display of inventory/label batches to reflect multiple handheld batches
This commit is contained in:
parent
1fc3133f8e
commit
a63f2e3623
|
@ -48,4 +48,4 @@ from .products import (GPCFieldRenderer, ScancodeFieldRenderer,
|
|||
|
||||
from .custorders import CustomerOrderFieldRenderer
|
||||
|
||||
from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer
|
||||
from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer, HandheldBatchesFieldRenderer
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue