More tweaks to support mobile inventory batches
This commit is contained in:
parent
8a5dbc33a7
commit
1791bd745b
|
@ -14,3 +14,11 @@ ${form.render()|n}
|
|||
<br />
|
||||
${grid.render_complete()|n}
|
||||
% endif
|
||||
|
||||
% if not batch.executed and not batch.complete:
|
||||
<br />
|
||||
${h.form(request.route_url('mobile.batch.inventory.mark_complete', uuid=batch.uuid))}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('mark-complete', value='true')}
|
||||
<button type="submit">Mark Batch as Complete</button>
|
||||
% endif
|
||||
|
|
|
@ -395,6 +395,11 @@ class BatchMasterView(MasterView):
|
|||
|
||||
return self.render_to_response('edit', context)
|
||||
|
||||
def mobile_mark_complete(self):
|
||||
batch = self.get_instance()
|
||||
batch.complete = True
|
||||
return self.redirect(self.get_index_url(mobile=True))
|
||||
|
||||
def rows_creatable_for(self, batch):
|
||||
"""
|
||||
Only allow creating new rows on a batch if it hasn't yet been executed.
|
||||
|
@ -992,6 +997,7 @@ class BatchMasterView(MasterView):
|
|||
|
||||
@classmethod
|
||||
def _batch_defaults(cls, config):
|
||||
model_key = cls.get_model_key()
|
||||
route_prefix = cls.get_route_prefix()
|
||||
url_prefix = cls.get_url_prefix()
|
||||
permission_prefix = cls.get_permission_prefix()
|
||||
|
@ -1022,6 +1028,12 @@ class BatchMasterView(MasterView):
|
|||
config.add_tailbone_permission(permission_prefix, '{}.delete_rows'.format(permission_prefix),
|
||||
"Bulk-delete data rows from {}".format(model_title))
|
||||
|
||||
# mobile mark complete
|
||||
config.add_route('mobile.{}.mark_complete'.format(route_prefix), '/mobile{}/{{{}}}/mark-complete'.format(url_prefix, model_key))
|
||||
config.add_view(cls, attr='mobile_mark_complete', route_name='mobile.{}.mark_complete'.format(route_prefix),
|
||||
permission='{}.edit'.format(permission_prefix))
|
||||
|
||||
|
||||
# execute batch
|
||||
config.add_route('{}.execute'.format(route_prefix), '{}/{{uuid}}/execute'.format(url_prefix))
|
||||
config.add_view(cls, attr='execute', route_name='{}.execute'.format(route_prefix),
|
||||
|
|
|
@ -92,6 +92,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
fs.created_by,
|
||||
fs.handheld_batches,
|
||||
fs.mode,
|
||||
fs.reason_code,
|
||||
fs.rowcount,
|
||||
fs.complete,
|
||||
fs.executed,
|
||||
|
@ -101,6 +102,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
def configure_mobile_fieldset(self, fs):
|
||||
fs.configure(include=[
|
||||
fs.mode,
|
||||
fs.reason_code,
|
||||
fs.rowcount,
|
||||
fs.complete,
|
||||
fs.executed,
|
||||
|
@ -157,6 +159,7 @@ class InventoryBatchView(BatchMasterView):
|
|||
kwargs = super(InventoryBatchView, self).get_batch_kwargs(batch, mobile=False)
|
||||
kwargs['mode'] = batch.mode
|
||||
kwargs['complete'] = False
|
||||
kwargs['reason_code'] = batch.reason_code
|
||||
return kwargs
|
||||
|
||||
def get_mobile_row_data(self, batch):
|
||||
|
@ -282,7 +285,7 @@ class InventoryBatchRenderer(fa.FieldRenderer):
|
|||
batch.id_str,
|
||||
"?" if batch.rowcount is None else batch.rowcount,
|
||||
batch.created_by,
|
||||
localtime(self.request.rattail_config, batch.created).strftime('%Y-%m-%d'))
|
||||
localtime(self.request.rattail_config, batch.created, from_utc=True).strftime('%Y-%m-%d'))
|
||||
url = self.request.route_url('mobile.batch.inventory.view', uuid=batch.uuid)
|
||||
return tags.link_to(title, url)
|
||||
|
||||
|
|
|
@ -326,11 +326,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
row.credits.append(credit)
|
||||
return credit
|
||||
|
||||
def mobile_mark_complete(self):
|
||||
batch = self.get_instance()
|
||||
batch.complete = True
|
||||
return self.redirect(self.request.route_url('mobile.{}'.format(self.get_route_prefix())))
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
route_prefix = cls.get_route_prefix()
|
||||
|
@ -344,11 +339,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
config.add_view(cls, attr='mobile_lookup', route_name='mobile.{}.lookup'.format(route_prefix),
|
||||
renderer='json', permission='{}.create'.format(row_permission_prefix))
|
||||
|
||||
# mobile mark complete
|
||||
config.add_route('mobile.{}.mark_complete'.format(route_prefix), '/mobile{}/{{{}}}/mark-complete'.format(url_prefix, model_key))
|
||||
config.add_view(cls, attr='mobile_mark_complete', route_name='mobile.{}.mark_complete'.format(route_prefix),
|
||||
permission='{}.edit'.format(permission_prefix))
|
||||
|
||||
cls._purchasing_defaults(config)
|
||||
cls._batch_defaults(config)
|
||||
cls._defaults(config)
|
||||
|
|
Loading…
Reference in a new issue