Make handler responsible for possible receiving modes
This commit is contained in:
parent
708641a8f1
commit
ff2e39f67a
|
@ -7,7 +7,7 @@
|
|||
${self.func_show_batch_type()}
|
||||
<script type="text/javascript">
|
||||
|
||||
% if master.allow_truck_dump:
|
||||
% if master.handler.allow_truck_dump_receiving():
|
||||
var batch_vendor_map = ${json.dumps(batch_vendor_map)|n};
|
||||
% endif
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@
|
|||
<%def name="object_helpers()">
|
||||
${parent.object_helpers()}
|
||||
## TODO: for now this is a truck-dump-only feature? maybe should change that
|
||||
% if not request.rattail_config.production() and master.allow_truck_dump:
|
||||
% if not request.rattail_config.production() and master.handler.allow_truck_dump_receiving():
|
||||
% if not batch.executed and not batch.complete and request.has_perm('admin'):
|
||||
% if (batch.is_truck_dump_parent() and batch.truck_dump_children_first) or not batch.is_truck_dump_related():
|
||||
<div class="object-helper">
|
||||
|
@ -306,7 +306,7 @@
|
|||
|
||||
${parent.body()}
|
||||
|
||||
% if master.allow_truck_dump and request.has_perm('{}.edit_row'.format(permission_prefix)):
|
||||
% if master.handler.allow_truck_dump_receiving() and master.has_perm('edit_row'):
|
||||
${h.form(url('{}.transform_unit_row'.format(route_prefix), uuid=batch.uuid), name='transform-unit-form')}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('row_uuid')}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2020 Lance Edgar
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -66,10 +66,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
bulk_deletable = True
|
||||
rows_editable = True
|
||||
|
||||
allow_from_po = False
|
||||
allow_from_scratch = True
|
||||
allow_truck_dump = False
|
||||
|
||||
default_uom_is_case = True
|
||||
|
||||
purchase_order_fieldname = 'purchase'
|
||||
|
@ -246,15 +242,16 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
def configure_form(self, f):
|
||||
super(ReceivingBatchView, self).configure_form(f)
|
||||
batch = f.model_instance
|
||||
allow_truck_dump = self.handler.allow_truck_dump_receiving()
|
||||
|
||||
# batch_type
|
||||
if self.creating:
|
||||
batch_types = OrderedDict()
|
||||
if self.allow_from_scratch:
|
||||
if self.handler.allow_receiving_from_scratch():
|
||||
batch_types['from_scratch'] = "From Scratch"
|
||||
if self.allow_from_po:
|
||||
if self.handler.allow_receiving_from_purchase_order():
|
||||
batch_types['from_po'] = "From PO"
|
||||
if self.allow_truck_dump:
|
||||
if allow_truck_dump:
|
||||
batch_types['truck_dump_children_first'] = "Truck Dump (children FIRST)"
|
||||
batch_types['truck_dump_children_last'] = "Truck Dump (children LAST)"
|
||||
f.set_enum('batch_type', batch_types)
|
||||
|
@ -262,7 +259,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
f.remove_field('batch_type')
|
||||
|
||||
# truck_dump*
|
||||
if self.allow_truck_dump:
|
||||
if allow_truck_dump:
|
||||
|
||||
# truck_dump
|
||||
if self.creating or not batch.is_truck_dump_parent():
|
||||
|
@ -367,7 +364,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
|
||||
def template_kwargs_create(self, **kwargs):
|
||||
kwargs = super(ReceivingBatchView, self).template_kwargs_create(**kwargs)
|
||||
if self.allow_truck_dump:
|
||||
if self.handler.allow_truck_dump_receiving():
|
||||
vmap = {}
|
||||
batches = self.Session.query(model.PurchaseBatch)\
|
||||
.filter(model.PurchaseBatch.mode == self.enum.PURCHASE_BATCH_MODE_RECEIVING)\
|
||||
|
@ -1300,24 +1297,22 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
permission='{}.edit_row'.format(permission_prefix),
|
||||
renderer='json')
|
||||
|
||||
if cls.allow_truck_dump:
|
||||
# add TD child batch, from invoice file
|
||||
config.add_route('{}.add_child_from_invoice'.format(route_prefix), '{}/{{{}}}/add-child-from-invoice'.format(url_prefix, model_key))
|
||||
config.add_view(cls, attr='add_child_from_invoice', route_name='{}.add_child_from_invoice'.format(route_prefix),
|
||||
permission='{}.create'.format(permission_prefix))
|
||||
|
||||
# add TD child batch, from invoice file
|
||||
config.add_route('{}.add_child_from_invoice'.format(route_prefix), '{}/{{{}}}/add-child-from-invoice'.format(url_prefix, model_key))
|
||||
config.add_view(cls, attr='add_child_from_invoice', route_name='{}.add_child_from_invoice'.format(route_prefix),
|
||||
permission='{}.create'.format(permission_prefix))
|
||||
# transform TD parent row from "pack" to "unit" item
|
||||
config.add_route('{}.transform_unit_row'.format(route_prefix), '{}/{{{}}}/transform-unit'.format(url_prefix, model_key))
|
||||
config.add_view(cls, attr='transform_unit_row', route_name='{}.transform_unit_row'.format(route_prefix),
|
||||
permission='{}.edit_row'.format(permission_prefix), renderer='json')
|
||||
|
||||
# transform TD parent row from "pack" to "unit" item
|
||||
config.add_route('{}.transform_unit_row'.format(route_prefix), '{}/{{{}}}/transform-unit'.format(url_prefix, model_key))
|
||||
config.add_view(cls, attr='transform_unit_row', route_name='{}.transform_unit_row'.format(route_prefix),
|
||||
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(url_prefix, model_key),
|
||||
request_method='POST')
|
||||
config.add_view(cls, attr='auto_receive', route_name='{}.auto_receive'.format(route_prefix),
|
||||
permission='admin')
|
||||
# auto-receive all items
|
||||
if not rattail_config.production():
|
||||
config.add_route('{}.auto_receive'.format(route_prefix), '{}/{{{}}}/auto-receive'.format(url_prefix, model_key),
|
||||
request_method='POST')
|
||||
config.add_view(cls, attr='auto_receive', route_name='{}.auto_receive'.format(route_prefix),
|
||||
permission='admin')
|
||||
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in a new issue