diff --git a/tailbone/templates/custorders/create.mako b/tailbone/templates/custorders/create.mako index 866312c9..7cab2d0b 100644 --- a/tailbone/templates/custorders/create.mako +++ b/tailbone/templates/custorders/create.mako @@ -217,9 +217,13 @@ + ref="productUPCInput" + @keydown.native="productUPCKeyDown"> Fetch @@ -228,6 +232,14 @@ {{ productUPC }} (click to change) + + View Product + @@ -296,6 +308,10 @@ {{ props.row.product_size }} + + {{ props.row.department_display }} + + @@ -304,6 +320,10 @@ {{ props.row.total_price_display }} + + {{ props.row.vendor_display }} + + @@ -734,6 +754,12 @@ }) }, + productUPCKeyDown(event) { + if (event.which == 13) { // Enter + this.fetchProductByUPC() + } + }, + productChanged(uuid) { if (uuid) { this.productUUID = uuid diff --git a/tailbone/views/custorders/batch.py b/tailbone/views/custorders/batch.py index bfbb5c02..9f685671 100644 --- a/tailbone/views/custorders/batch.py +++ b/tailbone/views/custorders/batch.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -52,6 +52,8 @@ class CustomerOrderBatchView(BatchMasterView): 'total_price', 'created', 'created_by', + 'executed', + 'executed_by', ] form_fields = [ diff --git a/tailbone/views/custorders/orders.py b/tailbone/views/custorders/orders.py index 29d5b7a3..e2be9ff5 100644 --- a/tailbone/views/custorders/orders.py +++ b/tailbone/views/custorders/orders.py @@ -32,7 +32,7 @@ import six from sqlalchemy import orm from rattail import pod -from rattail.db import api, model +from rattail.db import model from rattail.util import pretty_quantity from rattail.batch import get_batch_handler @@ -263,7 +263,8 @@ class CustomerOrderView(MasterView): if not upc: return {'error': "Must specify a product UPC"} - product = api.get_product_by_upc(self.Session(), upc) + product = self.handler.locate_product_for_entry( + self.Session(), upc, product_key='upc') if not product: return {'error': "Product not found"} @@ -299,14 +300,15 @@ class CustomerOrderView(MasterView): # Case case_text = None - if product.case_size is None: + case_size = self.handler.get_case_size_for_product(product) + if case_size is None: case_text = "{} (× ?? {})".format( self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE], unit_name) - elif product.case_size > 1: + elif case_size > 1: case_text = "{} (× {} {})".format( self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE], - pretty_quantity(product.case_size), + pretty_quantity(case_size), unit_name) if case_text: choices.append({'key': self.enum.UNIT_OF_MEASURE_CASE, @@ -334,6 +336,9 @@ class CustomerOrderView(MasterView): } def normalize_row(self, row): + product = row.product + department = product.department if product else None + cost = product.cost if product else None data = { 'uuid': row.uuid, 'sequence': row.sequence, @@ -344,7 +349,7 @@ class CustomerOrderView(MasterView): 'product_brand': row.product_brand, 'product_description': row.product_description, 'product_size': row.product_size, - 'product_full_description': row.product.full_description if row.product else row.product_description, + 'product_full_description': product.full_description if product else row.product_description, 'product_weighed': row.product_weighed, 'case_quantity': pretty_quantity(row.case_quantity), @@ -352,7 +357,10 @@ class CustomerOrderView(MasterView): 'units_ordered': pretty_quantity(row.units_ordered), 'order_quantity': pretty_quantity(row.order_quantity), 'order_uom': row.order_uom, - 'order_uom_choices': self.uom_choices_for_product(row.product), + 'order_uom_choices': self.uom_choices_for_product(product), + + 'department_display': department.name if department else None, + 'vendor_display': cost.vendor.name if cost else None, 'unit_price': six.text_type(row.unit_price) if row.unit_price is not None else None, 'unit_price_display': "${:0.2f}".format(row.unit_price) if row.unit_price is not None else None, @@ -468,7 +476,7 @@ class CustomerOrderView(MasterView): 'batch': self.normalize_batch(batch)} def submit_new_order(self, batch, data): - result = self.handler.do_execute(batch, self.request.user) + result = self.execute_new_order_batch(batch, data) if not result: return {'error': "Batch failed to execute"} @@ -478,6 +486,9 @@ class CustomerOrderView(MasterView): return {'ok': True, 'next_url': next_url} + def execute_new_order_batch(self, batch, data): + return self.handler.do_execute(batch, self.request.user) + # TODO: deprecate / remove this CustomerOrdersView = CustomerOrderView