Add basic views for label batches
This commit is contained in:
parent
5183184b16
commit
4cfd3aa00e
|
@ -49,4 +49,4 @@ from .stores import StoreFieldRenderer
|
|||
|
||||
from .vendors import VendorFieldRenderer
|
||||
|
||||
from .batch import BatchIDFieldRenderer
|
||||
from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer
|
||||
|
|
|
@ -33,6 +33,7 @@ import random
|
|||
import formalchemy as fa
|
||||
from formalchemy.ext import fsblob
|
||||
from formalchemy.fields import FileFieldRenderer as Base
|
||||
from webhelpers.html import tags
|
||||
|
||||
|
||||
class BatchIDFieldRenderer(fa.FieldRenderer):
|
||||
|
@ -86,3 +87,17 @@ class FileFieldRenderer(fsblob.FileFieldRenderer):
|
|||
|
||||
def render(self, **kwargs):
|
||||
return Base.render(self, **kwargs)
|
||||
|
||||
|
||||
class HandheldBatchFieldRenderer(fa.FieldRenderer):
|
||||
"""
|
||||
Renderer for inventory batch's "handheld batch" field.
|
||||
"""
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
batch = self.raw_value
|
||||
if batch:
|
||||
return tags.link_to(
|
||||
batch.id_str,
|
||||
self.request.route_url('batch.handheld.view', uuid=batch.uuid))
|
||||
return ''
|
||||
|
|
|
@ -161,7 +161,10 @@ 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':
|
||||
return self.request.route_url('batch.rows', uuid=result.uuid)
|
||||
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 super(HandheldBatchView, self).get_execute_success_url(batch)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -30,27 +30,10 @@ from rattail import enum
|
|||
from rattail.db import model
|
||||
from rattail.db.batch.inventory.handler import InventoryBatchHandler
|
||||
|
||||
import formalchemy as fa
|
||||
from webhelpers.html import tags
|
||||
|
||||
from tailbone import forms
|
||||
from tailbone.views.batch import BatchMasterView
|
||||
|
||||
|
||||
class HandheldBatchFieldRenderer(fa.FieldRenderer):
|
||||
"""
|
||||
Renderer for inventory batch's "handheld batch" field.
|
||||
"""
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
batch = self.raw_value
|
||||
if batch:
|
||||
return tags.link_to(
|
||||
batch.id_str,
|
||||
self.request.route_url('batch.handheld.view', uuid=batch.uuid))
|
||||
return ''
|
||||
|
||||
|
||||
class InventoryBatchView(BatchMasterView):
|
||||
"""
|
||||
Master view for inventory batches.
|
||||
|
@ -78,7 +61,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
|
||||
def _preconfigure_fieldset(self, fs):
|
||||
super(InventoryBatchView, self)._preconfigure_fieldset(fs)
|
||||
fs.handheld_batch.set(renderer=HandheldBatchFieldRenderer, readonly=True)
|
||||
fs.handheld_batch.set(renderer=forms.renderers.HandheldBatchFieldRenderer, readonly=True)
|
||||
fs.mode.set(renderer=forms.renderers.EnumFieldRenderer(enum.INVENTORY_MODE),
|
||||
label="Count Mode")
|
||||
|
||||
|
|
164
tailbone/views/labels/batch.py
Normal file
164
tailbone/views/labels/batch.py
Normal file
|
@ -0,0 +1,164 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2016 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Views for label batches
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from rattail.db import model
|
||||
from rattail.db.batch.labels.handler import LabelBatchHandler
|
||||
|
||||
from tailbone import forms
|
||||
from tailbone.views.batch import BatchMasterView
|
||||
|
||||
|
||||
class LabelBatchView(BatchMasterView):
|
||||
"""
|
||||
Master view for label batches.
|
||||
"""
|
||||
model_class = model.LabelBatch
|
||||
model_row_class = model.LabelBatchRow
|
||||
batch_handler_class = LabelBatchHandler
|
||||
model_title_plural = "Label Batches"
|
||||
route_prefix = 'labels.batch'
|
||||
url_prefix = '/labels/batches'
|
||||
creatable = False
|
||||
editable = False
|
||||
rows_editable = True
|
||||
|
||||
def _preconfigure_fieldset(self, fs):
|
||||
super(LabelBatchView, self)._preconfigure_fieldset(fs)
|
||||
fs.handheld_batch.set(renderer=forms.renderers.HandheldBatchFieldRenderer, readonly=True)
|
||||
|
||||
def configure_fieldset(self, fs):
|
||||
fs.configure(
|
||||
include=[
|
||||
fs.id,
|
||||
fs.created,
|
||||
fs.created_by,
|
||||
fs.handheld_batch,
|
||||
fs.executed,
|
||||
fs.executed_by,
|
||||
])
|
||||
|
||||
def _preconfigure_row_grid(self, g):
|
||||
super(LabelBatchView, self)._preconfigure_row_grid(g)
|
||||
g.upc.set(label="UPC")
|
||||
g.brand_name.set(label="Brand")
|
||||
g.regular_price.set(label="Reg Price")
|
||||
g.label_profile.set(label="Label Type")
|
||||
g.label_quantity.set(label="Qty")
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
g.configure(
|
||||
include=[
|
||||
g.sequence,
|
||||
g.upc,
|
||||
g.brand_name,
|
||||
g.description,
|
||||
g.size,
|
||||
g.regular_price,
|
||||
g.sale_price,
|
||||
g.label_profile,
|
||||
g.label_quantity,
|
||||
g.status_code,
|
||||
],
|
||||
readonly=True)
|
||||
|
||||
def row_grid_row_attrs(self, row, i):
|
||||
attrs = {}
|
||||
if row.status_code != row.STATUS_OK:
|
||||
attrs['class_'] = 'warning'
|
||||
return attrs
|
||||
|
||||
def _preconfigure_row_fieldset(self, fs):
|
||||
fs.sequence.set(readonly=True)
|
||||
fs.product.set(readonly=True)
|
||||
fs.upc.set(readonly=True, label="UPC")
|
||||
fs.brand_name.set(readonly=True)
|
||||
fs.description.set(readonly=True)
|
||||
fs.size.set(readonly=True)
|
||||
fs.department_number.set(readonly=True)
|
||||
fs.department_name.set(readonly=True)
|
||||
fs.regular_price.set(readonly=True)
|
||||
fs.pack_quantity.set(readonly=True)
|
||||
fs.pack_price.set(readonly=True)
|
||||
fs.sale_price.set(readonly=True)
|
||||
fs.sale_start.set(readonly=True)
|
||||
fs.sale_stop.set(readonly=True)
|
||||
fs.vendor_id.set(readonly=True, label="Vendor ID")
|
||||
fs.vendor_name.set(readonly=True)
|
||||
fs.vendor_item_code.set(readonly=True)
|
||||
fs.case_quantity.set(readonly=True)
|
||||
fs.status_code.set(readonly=True)
|
||||
fs.status_text.set(readonly=True)
|
||||
|
||||
fs.label_profile.set(label="Label Type")
|
||||
|
||||
def configure_row_fieldset(self, fs):
|
||||
if self.viewing:
|
||||
fs.configure(
|
||||
include=[
|
||||
fs.sequence,
|
||||
fs.upc,
|
||||
fs.brand_name,
|
||||
fs.description,
|
||||
fs.size,
|
||||
fs.department_number,
|
||||
fs.department_name,
|
||||
fs.regular_price,
|
||||
fs.pack_quantity,
|
||||
fs.pack_price,
|
||||
fs.sale_price,
|
||||
fs.sale_start,
|
||||
fs.sale_stop,
|
||||
fs.vendor_id,
|
||||
fs.vendor_name,
|
||||
fs.vendor_item_code,
|
||||
fs.case_quantity,
|
||||
fs.label_profile,
|
||||
fs.label_quantity,
|
||||
fs.status_code,
|
||||
fs.status_text,
|
||||
])
|
||||
|
||||
elif self.editing:
|
||||
fs.configure(
|
||||
include=[
|
||||
fs.sequence,
|
||||
fs.upc,
|
||||
fs.product,
|
||||
fs.department_number,
|
||||
fs.department_name,
|
||||
fs.regular_price,
|
||||
fs.sale_price,
|
||||
fs.label_profile,
|
||||
fs.label_quantity,
|
||||
fs.status_code,
|
||||
fs.status_text,
|
||||
])
|
||||
|
||||
|
||||
def includeme(config):
|
||||
LabelBatchView.defaults(config)
|
Loading…
Reference in a new issue