Add "auto-receive all items" support for receiving batch API
This commit is contained in:
parent
f33d7b7f90
commit
ad7b347e16
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2021 Lance Edgar
|
# Copyright © 2010-2022 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -74,6 +74,8 @@ class ReceivingBatchViews(APIBatchView):
|
||||||
data['invoice_total'] = batch.invoice_total
|
data['invoice_total'] = batch.invoice_total
|
||||||
data['invoice_total_calculated'] = batch.invoice_total_calculated
|
data['invoice_total_calculated'] = batch.invoice_total_calculated
|
||||||
|
|
||||||
|
data['can_auto_receive'] = self.handler.can_auto_receive(batch)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def create_object(self, data):
|
def create_object(self, data):
|
||||||
|
@ -82,6 +84,15 @@ class ReceivingBatchViews(APIBatchView):
|
||||||
batch = super(ReceivingBatchViews, self).create_object(data)
|
batch = super(ReceivingBatchViews, self).create_object(data)
|
||||||
return batch
|
return batch
|
||||||
|
|
||||||
|
def auto_receive(self):
|
||||||
|
"""
|
||||||
|
View which handles auto-marking as received, all items within
|
||||||
|
a pending batch.
|
||||||
|
"""
|
||||||
|
batch = self.get_object()
|
||||||
|
self.handler.auto_receive_all_items(batch)
|
||||||
|
return self._get(obj=batch)
|
||||||
|
|
||||||
def mark_receiving_complete(self):
|
def mark_receiving_complete(self):
|
||||||
"""
|
"""
|
||||||
Mark the given batch as "receiving complete".
|
Mark the given batch as "receiving complete".
|
||||||
|
@ -136,6 +147,14 @@ class ReceivingBatchViews(APIBatchView):
|
||||||
collection_url_prefix = cls.get_collection_url_prefix()
|
collection_url_prefix = cls.get_collection_url_prefix()
|
||||||
object_url_prefix = cls.get_object_url_prefix()
|
object_url_prefix = cls.get_object_url_prefix()
|
||||||
|
|
||||||
|
# auto-receive
|
||||||
|
config.add_route('{}.auto_receive'.format(route_prefix),
|
||||||
|
'{}/{{uuid}}/auto-receive'.format(object_url_prefix))
|
||||||
|
config.add_view(cls, attr='auto_receive',
|
||||||
|
route_name='{}.auto_receive'.format(route_prefix),
|
||||||
|
permission='{}.auto_receive'.format(permission_prefix),
|
||||||
|
renderer='json')
|
||||||
|
|
||||||
# mark receiving complete
|
# mark receiving complete
|
||||||
config.add_route('{}.mark_receiving_complete'.format(route_prefix), '{}/{{uuid}}/mark-receiving-complete'.format(object_url_prefix))
|
config.add_route('{}.mark_receiving_complete'.format(route_prefix), '{}/{{uuid}}/mark-receiving-complete'.format(object_url_prefix))
|
||||||
config.add_view(cls, attr='mark_receiving_complete', route_name='{}.mark_receiving_complete'.format(route_prefix),
|
config.add_view(cls, attr='mark_receiving_complete', route_name='{}.mark_receiving_complete'.format(route_prefix),
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
</b-checkbox>
|
</b-checkbox>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
<b-field>
|
<b-field message="If set, one or more "quick receive" buttons will be available for mobile receiving.">
|
||||||
<b-checkbox name="rattail.batch.purchase.mobile_quick_receive"
|
<b-checkbox name="rattail.batch.purchase.mobile_quick_receive"
|
||||||
v-model="simpleSettings['rattail.batch.purchase.mobile_quick_receive']"
|
v-model="simpleSettings['rattail.batch.purchase.mobile_quick_receive']"
|
||||||
native-value="true"
|
native-value="true"
|
||||||
|
@ -138,12 +138,12 @@
|
||||||
</b-checkbox>
|
</b-checkbox>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
<b-field>
|
<b-field message="If set, only a "quick receive all" button will be shown. Only applicable if quick receive (above) is enabled.">
|
||||||
<b-checkbox name="rattail.batch.purchase.mobile_quick_receive_all"
|
<b-checkbox name="rattail.batch.purchase.mobile_quick_receive_all"
|
||||||
v-model="simpleSettings['rattail.batch.purchase.mobile_quick_receive_all']"
|
v-model="simpleSettings['rattail.batch.purchase.mobile_quick_receive_all']"
|
||||||
native-value="true"
|
native-value="true"
|
||||||
@input="settingsNeedSaved = true">
|
@input="settingsNeedSaved = true">
|
||||||
Allow "Quick Receive All"
|
Quick Receive "All or Nothing"
|
||||||
</b-checkbox>
|
</b-checkbox>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,9 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
'vendor_contact',
|
'vendor_contact',
|
||||||
'vendor_phone',
|
'vendor_phone',
|
||||||
'date_ordered',
|
'date_ordered',
|
||||||
'date_received',
|
|
||||||
'po_number',
|
'po_number',
|
||||||
'po_total',
|
'po_total',
|
||||||
|
'date_received',
|
||||||
'invoice_date',
|
'invoice_date',
|
||||||
'invoice_number',
|
'invoice_number',
|
||||||
'invoice_total',
|
'invoice_total',
|
||||||
|
@ -1824,22 +1824,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
return pod.get_image_url(self.rattail_config, row.upc)
|
return pod.get_image_url(self.rattail_config, row.upc)
|
||||||
|
|
||||||
def can_auto_receive(self, batch):
|
def can_auto_receive(self, batch):
|
||||||
if batch.executed:
|
return self.handler.can_auto_receive(batch)
|
||||||
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):
|
def auto_receive(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1865,7 +1850,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
"""
|
"""
|
||||||
session = RattailSession()
|
session = RattailSession()
|
||||||
batch = session.query(model.PurchaseBatch).get(uuid)
|
batch = session.query(model.PurchaseBatch).get(uuid)
|
||||||
user = session.query(model.User).get(user_uuid)
|
# user = session.query(model.User).get(user_uuid)
|
||||||
try:
|
try:
|
||||||
self.handler.auto_receive_all_items(batch, progress=progress)
|
self.handler.auto_receive_all_items(batch, progress=progress)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue