Improve UI, customization hooks for new custorder batch

still not done yet, but a savepoint
This commit is contained in:
Lance Edgar 2021-08-29 16:38:30 -05:00
parent 4d742bacb1
commit c2ea1be83f
3 changed files with 49 additions and 10 deletions

View file

@ -217,9 +217,13 @@
<b-field label="UPC" horizontal expanded>
<b-input v-if="!productUUID"
v-model="productUPC"
ref="productUPCInput">
ref="productUPCInput"
@keydown.native="productUPCKeyDown">
</b-input>
<b-button v-if="!productUUID"
type="is-primary"
icon-pack="fas"
icon-left="search"
@click="fetchProductByUPC()">
Fetch
</b-button>
@ -228,6 +232,14 @@
{{ productUPC }} (click to change)
</b-button>
</b-field>
<b-button v-if="productUUID"
type="is-primary"
tag="a" target="_blank"
:href="'${request.route_url('products')}/' + productUUID"
icon-pack="fas"
icon-left="external-link-alt">
View Product
</b-button>
</b-field>
</div>
@ -296,6 +308,10 @@
{{ props.row.product_size }}
</b-table-column>
<b-table-column field="department_display" label="Department">
{{ props.row.department_display }}
</b-table-column>
<b-table-column field="order_quantity_display" label="Quantity">
<span v-html="props.row.order_quantity_display"></span>
</b-table-column>
@ -304,6 +320,10 @@
{{ props.row.total_price_display }}
</b-table-column>
<b-table-column field="vendor_display" label="Vendor">
{{ props.row.vendor_display }}
</b-table-column>
<b-table-column field="actions" label="Actions">
<a href="#" class="grid-action"
@click.prevent="showEditItemDialog(props.index)">
@ -734,6 +754,12 @@
})
},
productUPCKeyDown(event) {
if (event.which == 13) { // Enter
this.fetchProductByUPC()
}
},
productChanged(uuid) {
if (uuid) {
this.productUUID = uuid

View file

@ -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 = [

View file

@ -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 = "{} (&times; ?? {})".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 = "{} (&times; {} {})".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