From 076d3d81895b89ef3e520ef58e0699058492f969 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 27 Jun 2018 13:43:03 -0500 Subject: [PATCH] Add support for zero quantity for mobile inventory batch rows --- .../templates/mobile/batch/inventory/view_row.mako | 12 +++++++++++- tailbone/templates/mobile/keypad.mako | 2 +- tailbone/views/inventory.py | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tailbone/templates/mobile/batch/inventory/view_row.mako b/tailbone/templates/mobile/batch/inventory/view_row.mako index d4d49f75..8643da1e 100644 --- a/tailbone/templates/mobile/batch/inventory/view_row.mako +++ b/tailbone/templates/mobile/batch/inventory/view_row.mako @@ -53,7 +53,17 @@ % endif ${h.hidden('units')} - ${keypad(unit_uom, uom, quantity=(row.cases or row.units or 1) if allow_cases else (row.units or 1), allow_cases=allow_cases)} + <% + quantity = 1 + if allow_cases: + if row.cases is not None: + quantity = row.cases + elif row.units is not None: + quantity = row.units + elif row.units is not None: + quantity = row.units + %> + ${keypad(unit_uom, uom, quantity=quantity, allow_cases=allow_cases)}
diff --git a/tailbone/templates/mobile/keypad.mako b/tailbone/templates/mobile/keypad.mako index 8f0f131d..38cb03da 100644 --- a/tailbone/templates/mobile/keypad.mako +++ b/tailbone/templates/mobile/keypad.mako @@ -29,7 +29,7 @@
- + % if allow_cases: ${h.radio('keypad-uom', value='CS', checked=selected_uom == 'CS', label="CS")} diff --git a/tailbone/views/inventory.py b/tailbone/views/inventory.py index 6c0a16c2..57dcae36 100644 --- a/tailbone/views/inventory.py +++ b/tailbone/views/inventory.py @@ -588,12 +588,14 @@ class InventoryBatchView(BatchMasterView): row = self.Session.query(model.InventoryBatchRow).get(update_form.validated['row']) cases = update_form.validated['cases'] units = update_form.validated['units'] - if cases: + if cases is not colander.null: row.cases = cases row.units = None - elif units: + elif units is not colander.null: row.cases = None row.units = units + else: + raise NotImplementedError self.handler.refresh_row(row) route_prefix = self.get_route_prefix() return self.redirect(self.request.route_url('mobile.{}.view'.format(route_prefix), uuid=batch.uuid))