Make handler responsible for possible receiving modes

This commit is contained in:
Lance Edgar 2021-01-30 16:56:30 -06:00
parent 708641a8f1
commit ff2e39f67a
3 changed files with 24 additions and 29 deletions

View file

@ -7,7 +7,7 @@
${self.func_show_batch_type()} ${self.func_show_batch_type()}
<script type="text/javascript"> <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}; var batch_vendor_map = ${json.dumps(batch_vendor_map)|n};
% endif % endif

View file

@ -286,7 +286,7 @@
<%def name="object_helpers()"> <%def name="object_helpers()">
${parent.object_helpers()} ${parent.object_helpers()}
## TODO: for now this is a truck-dump-only feature? maybe should change that ## 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 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(): % if (batch.is_truck_dump_parent() and batch.truck_dump_children_first) or not batch.is_truck_dump_related():
<div class="object-helper"> <div class="object-helper">
@ -306,7 +306,7 @@
${parent.body()} ${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.form(url('{}.transform_unit_row'.format(route_prefix), uuid=batch.uuid), name='transform-unit-form')}
${h.csrf_token(request)} ${h.csrf_token(request)}
${h.hidden('row_uuid')} ${h.hidden('row_uuid')}

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -66,10 +66,6 @@ class ReceivingBatchView(PurchasingBatchView):
bulk_deletable = True bulk_deletable = True
rows_editable = True rows_editable = True
allow_from_po = False
allow_from_scratch = True
allow_truck_dump = False
default_uom_is_case = True default_uom_is_case = True
purchase_order_fieldname = 'purchase' purchase_order_fieldname = 'purchase'
@ -246,15 +242,16 @@ class ReceivingBatchView(PurchasingBatchView):
def configure_form(self, f): def configure_form(self, f):
super(ReceivingBatchView, self).configure_form(f) super(ReceivingBatchView, self).configure_form(f)
batch = f.model_instance batch = f.model_instance
allow_truck_dump = self.handler.allow_truck_dump_receiving()
# batch_type # batch_type
if self.creating: if self.creating:
batch_types = OrderedDict() batch_types = OrderedDict()
if self.allow_from_scratch: if self.handler.allow_receiving_from_scratch():
batch_types['from_scratch'] = "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" 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_first'] = "Truck Dump (children FIRST)"
batch_types['truck_dump_children_last'] = "Truck Dump (children LAST)" batch_types['truck_dump_children_last'] = "Truck Dump (children LAST)"
f.set_enum('batch_type', batch_types) f.set_enum('batch_type', batch_types)
@ -262,7 +259,7 @@ class ReceivingBatchView(PurchasingBatchView):
f.remove_field('batch_type') f.remove_field('batch_type')
# truck_dump* # truck_dump*
if self.allow_truck_dump: if allow_truck_dump:
# truck_dump # truck_dump
if self.creating or not batch.is_truck_dump_parent(): if self.creating or not batch.is_truck_dump_parent():
@ -367,7 +364,7 @@ class ReceivingBatchView(PurchasingBatchView):
def template_kwargs_create(self, **kwargs): def template_kwargs_create(self, **kwargs):
kwargs = super(ReceivingBatchView, self).template_kwargs_create(**kwargs) kwargs = super(ReceivingBatchView, self).template_kwargs_create(**kwargs)
if self.allow_truck_dump: if self.handler.allow_truck_dump_receiving():
vmap = {} vmap = {}
batches = self.Session.query(model.PurchaseBatch)\ batches = self.Session.query(model.PurchaseBatch)\
.filter(model.PurchaseBatch.mode == self.enum.PURCHASE_BATCH_MODE_RECEIVING)\ .filter(model.PurchaseBatch.mode == self.enum.PURCHASE_BATCH_MODE_RECEIVING)\
@ -1300,8 +1297,6 @@ class ReceivingBatchView(PurchasingBatchView):
permission='{}.edit_row'.format(permission_prefix), permission='{}.edit_row'.format(permission_prefix),
renderer='json') renderer='json')
if cls.allow_truck_dump:
# add TD child batch, from invoice file # 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_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), config.add_view(cls, attr='add_child_from_invoice', route_name='{}.add_child_from_invoice'.format(route_prefix),