Add allow_zero_all flag for inventory batch master

defaults to true, but setting to false should disable "zero all" count mode
This commit is contained in:
Lance Edgar 2018-05-22 20:18:47 -05:00
parent 961e0e801d
commit c9eeabecba

View file

@ -94,6 +94,9 @@ class InventoryBatchView(BatchMasterView):
mobile_creatable = True
mobile_rows_creatable = True
# set to False to disable "zero all" batch count mode
allow_zero_all = True
labels = {
'mode': "Count Mode",
}
@ -208,7 +211,7 @@ class InventoryBatchView(BatchMasterView):
modes.pop(self.enum.INVENTORY_MODE_REPLACE, None)
if hasattr(self.enum, 'INVENTORY_MODE_REPLACE_ADJUST'):
modes.pop(self.enum.INVENTORY_MODE_REPLACE_ADJUST, None)
if not self.request.has_perm('{}.create.zero'.format(permission_prefix)):
if not self.allow_zero_all or not self.request.has_perm('{}.create.zero'.format(permission_prefix)):
if hasattr(self.enum, 'INVENTORY_MODE_ZERO_ALL'):
modes.pop(self.enum.INVENTORY_MODE_ZERO_ALL, None)
return modes
@ -584,8 +587,9 @@ class InventoryBatchView(BatchMasterView):
# extra perms for creating batches per "mode"
config.add_tailbone_permission(permission_prefix, '{}.create.replace'.format(permission_prefix),
"Create new {} with 'replace' mode".format(model_title))
config.add_tailbone_permission(permission_prefix, '{}.create.zero'.format(permission_prefix),
"Create new {} with 'zero' mode".format(model_title))
if cls.allow_zero_all:
config.add_tailbone_permission(permission_prefix, '{}.create.zero'.format(permission_prefix),
"Create new {} with 'zero' mode".format(model_title))
# row UPC lookup, for desktop
config.add_route('{}.desktop_lookup'.format(route_prefix), '{}/{{{}}}/desktop-form/lookup'.format(url_prefix, model_key))