Set UPC renderer for delproduct batch row

This commit is contained in:
Lance Edgar 2021-07-15 13:29:31 -05:00
parent fb156d2e29
commit 8eee4a1cf0
4 changed files with 17 additions and 20 deletions

View file

@ -615,6 +615,16 @@ class BatchMasterView(MasterView):
def get_row_status_enum(self): def get_row_status_enum(self):
return self.model_row_class.STATUS 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): def render_row_status(self, row, column):
code = row.status_code code = row.status_code
if code is None: if code is None:

View file

@ -105,6 +105,13 @@ class DeleteProductBatchView(BatchMasterView):
row.STATUS_PENDING_CUSTOMER_ORDERS): row.STATUS_PENDING_CUSTOMER_ORDERS):
return 'notice' 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): def includeme(config):
DeleteProductBatchView.defaults(config) DeleteProductBatchView.defaults(config)

View file

@ -471,16 +471,6 @@ class InventoryBatchView(BatchMasterView):
if not self.allow_cases(row.batch): if not self.allow_cases(row.batch):
f.set_readonly('cases') 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 @classmethod
def defaults(cls, config): def defaults(cls, config):
cls._batch_defaults(config) cls._batch_defaults(config)

View file

@ -187,16 +187,6 @@ class HandheldBatchView(FileBatchMasterView):
# upc # upc
f.set_renderer('upc', self.render_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): def get_execute_success_url(self, batch, result, **kwargs):
if kwargs['action'] == 'make_inventory_batch': if kwargs['action'] == 'make_inventory_batch':
return self.request.route_url('batch.inventory.view', uuid=result.uuid) return self.request.route_url('batch.inventory.view', uuid=result.uuid)