Add view for InventoryAdjustmentReason model

This commit is contained in:
Lance Edgar 2018-01-05 18:37:16 -06:00
parent 067cd60e20
commit dd22c04573

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2017 Lance Edgar # Copyright © 2010-2018 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -36,13 +36,44 @@ from rattail.time import localtime
from rattail.gpc import GPC from rattail.gpc import GPC
from rattail.util import pretty_quantity from rattail.util import pretty_quantity
import colander
import formalchemy as fa import formalchemy as fa
import formencode as fe import formencode as fe
from tailbone import forms from tailbone import forms
from tailbone.views import MasterView3 as MasterView
from tailbone.views.batch import BatchMasterView2 as BatchMasterView from tailbone.views.batch import BatchMasterView2 as BatchMasterView
class InventoryAdjustmentReasonsView(MasterView):
"""
Master view for inventory adjustment reasons.
"""
model_class = model.InventoryAdjustmentReason
route_prefix = 'invadjust_reasons'
url_prefix = '/inventory-adjustment-reasons'
grid_columns = [
'code',
'description',
]
def configure_form(self, f):
super(InventoryAdjustmentReasonsView, self).configure_form(f)
# code
f.set_validator('code', self.unique_code)
def unique_code(self, node, value):
query = self.Session.query(model.InventoryAdjustmentReason)\
.filter(model.InventoryAdjustmentReason.code == value)
if self.editing:
reason = self.get_instance()
query = query.filter(model.InventoryAdjustmentReason.uuid != reason.uuid)
if query.count():
raise colander.Invalid(node, "Code must be unique")
class InventoryBatchView(BatchMasterView): class InventoryBatchView(BatchMasterView):
""" """
Master view for inventory batches. Master view for inventory batches.
@ -391,4 +422,5 @@ class InventoryForm(forms.Schema):
def includeme(config): def includeme(config):
InventoryAdjustmentReasonsView.defaults(config)
InventoryBatchView.defaults(config) InventoryBatchView.defaults(config)