Let inventory batch handler decide which count modes are available
This commit is contained in:
parent
6a58f5f5d3
commit
dc4531f545
|
@ -37,7 +37,7 @@ from rattail.db import model, api
|
||||||
from rattail.db.util import make_full_description
|
from rattail.db.util import make_full_description
|
||||||
from rattail.time import localtime
|
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, OrderedDict
|
||||||
|
|
||||||
import colander
|
import colander
|
||||||
from deform import widget as dfwidget
|
from deform import widget as dfwidget
|
||||||
|
@ -176,18 +176,15 @@ class InventoryBatchView(BatchMasterView):
|
||||||
|
|
||||||
def get_available_modes(self):
|
def get_available_modes(self):
|
||||||
permission_prefix = self.get_permission_prefix()
|
permission_prefix = self.get_permission_prefix()
|
||||||
modes = dict(self.enum.INVENTORY_MODE)
|
if self.request.is_root:
|
||||||
if not self.request.has_perm('{}.create.replace'.format(permission_prefix)):
|
modes = self.handler.get_count_modes()
|
||||||
if hasattr(self.enum, 'INVENTORY_MODE_REPLACE'):
|
else:
|
||||||
modes.pop(self.enum.INVENTORY_MODE_REPLACE, None)
|
modes = self.handler.get_allowed_count_modes(
|
||||||
if hasattr(self.enum, 'INVENTORY_MODE_REPLACE_ADJUST'):
|
self.Session(), self.request.user,
|
||||||
modes.pop(self.enum.INVENTORY_MODE_REPLACE_ADJUST, None)
|
permission_prefix=permission_prefix)
|
||||||
if not self.handler.allow_zero_all or not self.request.has_perm('{}.create.zero'.format(permission_prefix)):
|
|
||||||
if hasattr(self.enum, 'INVENTORY_MODE_ZERO_ALL'):
|
modes = OrderedDict([(mode['code'], mode['label'])
|
||||||
modes.pop(self.enum.INVENTORY_MODE_ZERO_ALL, None)
|
for mode in modes])
|
||||||
if not self.handler.allow_variance or not self.request.has_perm('{}.create.variance'.format(permission_prefix)):
|
|
||||||
if hasattr(self.enum, 'INVENTORY_MODE_VARIANCE'):
|
|
||||||
modes.pop(self.enum.INVENTORY_MODE_VARIANCE, None)
|
|
||||||
return modes
|
return modes
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
|
|
Loading…
Reference in a new issue