From c9eeabecba2e5c0d2ddf580ae5e79f5610b04611 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 22 May 2018 20:18:47 -0500 Subject: [PATCH] Add `allow_zero_all` flag for inventory batch master defaults to true, but setting to false should disable "zero all" count mode --- tailbone/views/inventory.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tailbone/views/inventory.py b/tailbone/views/inventory.py index b10ade6f..f3252d57 100644 --- a/tailbone/views/inventory.py +++ b/tailbone/views/inventory.py @@ -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))