From a24076f0ce6b4b02934a372eb8ad22ced89a334a Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 2 Aug 2018 16:58:38 -0500 Subject: [PATCH] Make sure we refresh batch status when adding a new row b/c whether or not it has a product will affect batch status. this also changes how we interpret UPC for unknown product, i.e. by default we now assume it does *not* have a check digit and that we should calculate that. probably just a matter of time before someone needs the opposite though.. --- tailbone/views/purchasing/receiving.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index b6e24dd8..7d21abb2 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -742,6 +742,7 @@ class ReceivingBatchView(PurchasingBatchView): row.product = other_row.product self.handler.add_row(batch, row) self.Session.flush() + self.handler.refresh_batch_status(batch) return row # try to locate product by uuid before other, more specific key @@ -751,6 +752,7 @@ class ReceivingBatchView(PurchasingBatchView): row.product = product self.handler.add_row(batch, row) self.Session.flush() + self.handler.refresh_batch_status(batch) return row key = self.rattail_config.product_key() @@ -767,6 +769,7 @@ class ReceivingBatchView(PurchasingBatchView): row.product = product self.handler.add_row(batch, row) self.Session.flush() + self.handler.refresh_batch_status(batch) return row # check for "bad" upc @@ -775,11 +778,16 @@ class ReceivingBatchView(PurchasingBatchView): # product not in system, but presumably sane upc, so add to batch anyway row = model.PurchaseBatchRow() - row.upc = provided # TODO: why not checked? how to know? + add_check_digit = True # TODO: make this dynamic, of course + if add_check_digit: + row.upc = checked + else: + row.upc = provided row.item_id = entry row.description = "(unknown product)" self.handler.add_row(batch, row) self.Session.flush() + self.handler.refresh_batch_status(batch) return row elif key == 'item_id': @@ -791,6 +799,7 @@ class ReceivingBatchView(PurchasingBatchView): row.product = product self.handler.add_row(batch, row) self.Session.flush() + self.handler.refresh_batch_status(batch) return row # check for "too long" item_id @@ -803,6 +812,7 @@ class ReceivingBatchView(PurchasingBatchView): row.description = "(unknown product)" self.handler.add_row(batch, row) self.Session.flush() + self.handler.refresh_batch_status(batch) return row else: