Allow "auto-receive all items" batch feature in production
but require a dedicated permission
This commit is contained in:
parent
10e34b83ed
commit
be92075abb
2 changed files with 45 additions and 29 deletions
|
@ -1469,6 +1469,24 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
if self.rattail_config.getbool('rattail.batch', 'purchase.mobile_images', default=True):
|
||||
return pod.get_image_url(self.rattail_config, row.upc)
|
||||
|
||||
def can_auto_receive(self, batch):
|
||||
if batch.executed:
|
||||
return False
|
||||
if batch.complete:
|
||||
return False
|
||||
|
||||
if batch.is_truck_dump_related():
|
||||
if not batch.is_truck_dump_parent():
|
||||
return False
|
||||
if not batch.truck_dump_children_first():
|
||||
return False
|
||||
|
||||
# only auto-receive once per batch
|
||||
if batch.get_param('auto_received'):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def auto_receive(self):
|
||||
"""
|
||||
View which can "auto-receive" all items in the batch. Meant only as a
|
||||
|
@ -1535,6 +1553,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
url_prefix = cls.get_url_prefix()
|
||||
instance_url_prefix = cls.get_instance_url_prefix()
|
||||
model_key = cls.get_model_key()
|
||||
model_title = cls.get_model_title()
|
||||
permission_prefix = cls.get_permission_prefix()
|
||||
|
||||
# new receiving batch using workflow X
|
||||
|
@ -1569,11 +1588,13 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
permission='{}.edit_row'.format(permission_prefix), renderer='json')
|
||||
|
||||
# auto-receive all items
|
||||
if not rattail_config.production():
|
||||
config.add_route('{}.auto_receive'.format(route_prefix), '{}/auto-receive'.format(instance_url_prefix),
|
||||
request_method='POST')
|
||||
config.add_view(cls, attr='auto_receive', route_name='{}.auto_receive'.format(route_prefix),
|
||||
permission='admin')
|
||||
config.add_tailbone_permission(permission_prefix,
|
||||
'{}.auto_receive'.format(permission_prefix),
|
||||
"Auto-receive all items for a {}".format(model_title))
|
||||
config.add_route('{}.auto_receive'.format(route_prefix), '{}/auto-receive'.format(instance_url_prefix),
|
||||
request_method='POST')
|
||||
config.add_view(cls, attr='auto_receive', route_name='{}.auto_receive'.format(route_prefix),
|
||||
permission='{}.auto_receive'.format(permission_prefix))
|
||||
|
||||
|
||||
@colander.deferred
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue