Honor view logic when displaying Delete Row button for mobile receiving
also do not allow quick receive if receiving from scratch
This commit is contained in:
parent
f0d8f79676
commit
a6a7d22ec1
|
@ -133,7 +133,7 @@
|
|||
${h.hidden('quick_receive', value='false')}
|
||||
${h.end_form()}
|
||||
|
||||
% if master.mobile_rows_deletable and request.has_perm('{}.delete_row'.format(permission_prefix)):
|
||||
% if master.mobile_rows_deletable and master.row_deletable(row) and request.has_perm('{}.delete_row'.format(permission_prefix)):
|
||||
${h.form(url('mobile.{}.delete_row'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid), class_='receiving-update')}
|
||||
${h.csrf_token(request)}
|
||||
${h.submit('submit', "Delete this Row")}
|
||||
|
|
|
@ -254,8 +254,22 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
|
||||
def row_deletable(self, row):
|
||||
batch = row.batch
|
||||
|
||||
# can always delete rows from truck dump parent
|
||||
if batch.is_truck_dump_parent():
|
||||
return True
|
||||
|
||||
# can never delete rows from truck dump child
|
||||
elif batch.is_truck_dump_child():
|
||||
return False
|
||||
|
||||
else: # okay, normal batch
|
||||
if batch.order_quantities_known:
|
||||
return False
|
||||
else: # allow delete if receiving rom scratch
|
||||
return True
|
||||
|
||||
# cannot delete row by default
|
||||
return False
|
||||
|
||||
def get_instance_title(self, batch):
|
||||
|
@ -1113,10 +1127,16 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
'form': form,
|
||||
'allow_expired': self.handler.allow_expired_credits(),
|
||||
'allow_cases': self.handler.allow_cases(),
|
||||
'quick_receive': self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive', default=True),
|
||||
'quick_receive_all': self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive_all', default=False)
|
||||
'quick_receive': False,
|
||||
'quick_receive_all': False,
|
||||
}
|
||||
|
||||
if batch.order_quantities_known:
|
||||
context['quick_receive'] = self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive',
|
||||
default=True)
|
||||
context['quick_receive_all'] = self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive_all',
|
||||
default=False)
|
||||
|
||||
if self.request.has_perm('{}.create_row'.format(permission_prefix)):
|
||||
schema = MobileReceivingForm().bind(session=self.Session())
|
||||
update_form = forms.Form(schema=schema, request=self.request)
|
||||
|
|
Loading…
Reference in a new issue