From 8eee4a1cf09891989bb9163fa7efa60ad340eea4 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 15 Jul 2021 13:29:31 -0500 Subject: [PATCH] Set UPC renderer for delproduct batch row --- tailbone/views/batch/core.py | 10 ++++++++++ tailbone/views/batch/delproduct.py | 7 +++++++ tailbone/views/batch/inventory.py | 10 ---------- tailbone/views/handheld.py | 10 ---------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 299f0a10..07b7ff68 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -615,6 +615,16 @@ class BatchMasterView(MasterView): def get_row_status_enum(self): return self.model_row_class.STATUS + def render_upc(self, row, field): + upc = row.upc + if not upc: + return "" + text = upc.pretty() + if row.product_uuid: + url = self.request.route_url('products.view', uuid=row.product_uuid) + return tags.link_to(text, url) + return text + def render_row_status(self, row, column): code = row.status_code if code is None: diff --git a/tailbone/views/batch/delproduct.py b/tailbone/views/batch/delproduct.py index 845de3db..287fb3e3 100644 --- a/tailbone/views/batch/delproduct.py +++ b/tailbone/views/batch/delproduct.py @@ -105,6 +105,13 @@ class DeleteProductBatchView(BatchMasterView): row.STATUS_PENDING_CUSTOMER_ORDERS): return 'notice' + def configure_row_form(self, f): + super(DeleteProductBatchView, self).configure_row_form(f) + row = f.model_instance + + # upc + f.set_renderer('upc', self.render_upc) + def includeme(config): DeleteProductBatchView.defaults(config) diff --git a/tailbone/views/batch/inventory.py b/tailbone/views/batch/inventory.py index adf91561..f8699725 100644 --- a/tailbone/views/batch/inventory.py +++ b/tailbone/views/batch/inventory.py @@ -471,16 +471,6 @@ class InventoryBatchView(BatchMasterView): if not self.allow_cases(row.batch): f.set_readonly('cases') - def render_upc(self, row, field): - upc = row.upc - if not upc: - return "" - text = upc.pretty() - if row.product_uuid: - url = self.request.route_url('products.view', uuid=row.product_uuid) - return tags.link_to(text, url) - return text - @classmethod def defaults(cls, config): cls._batch_defaults(config) diff --git a/tailbone/views/handheld.py b/tailbone/views/handheld.py index 66cd480c..b0392c13 100644 --- a/tailbone/views/handheld.py +++ b/tailbone/views/handheld.py @@ -187,16 +187,6 @@ class HandheldBatchView(FileBatchMasterView): # upc f.set_renderer('upc', self.render_upc) - def render_upc(self, row, field): - upc = row.upc - if not upc: - return "" - text = upc.pretty() - if row.product_uuid: - url = self.request.route_url('products.view', uuid=row.product_uuid) - return tags.link_to(text, url) - return text - def get_execute_success_url(self, batch, result, **kwargs): if kwargs['action'] == 'make_inventory_batch': return self.request.route_url('batch.inventory.view', uuid=result.uuid)