Improve UI, customization hooks for new custorder batch
still not done yet, but a savepoint
This commit is contained in:
parent
4d742bacb1
commit
c2ea1be83f
|
@ -217,9 +217,13 @@
|
||||||
<b-field label="UPC" horizontal expanded>
|
<b-field label="UPC" horizontal expanded>
|
||||||
<b-input v-if="!productUUID"
|
<b-input v-if="!productUUID"
|
||||||
v-model="productUPC"
|
v-model="productUPC"
|
||||||
ref="productUPCInput">
|
ref="productUPCInput"
|
||||||
|
@keydown.native="productUPCKeyDown">
|
||||||
</b-input>
|
</b-input>
|
||||||
<b-button v-if="!productUUID"
|
<b-button v-if="!productUUID"
|
||||||
|
type="is-primary"
|
||||||
|
icon-pack="fas"
|
||||||
|
icon-left="search"
|
||||||
@click="fetchProductByUPC()">
|
@click="fetchProductByUPC()">
|
||||||
Fetch
|
Fetch
|
||||||
</b-button>
|
</b-button>
|
||||||
|
@ -228,6 +232,14 @@
|
||||||
{{ productUPC }} (click to change)
|
{{ productUPC }} (click to change)
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-field>
|
</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>
|
</b-field>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -296,6 +308,10 @@
|
||||||
{{ props.row.product_size }}
|
{{ props.row.product_size }}
|
||||||
</b-table-column>
|
</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">
|
<b-table-column field="order_quantity_display" label="Quantity">
|
||||||
<span v-html="props.row.order_quantity_display"></span>
|
<span v-html="props.row.order_quantity_display"></span>
|
||||||
</b-table-column>
|
</b-table-column>
|
||||||
|
@ -304,6 +320,10 @@
|
||||||
{{ props.row.total_price_display }}
|
{{ props.row.total_price_display }}
|
||||||
</b-table-column>
|
</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">
|
<b-table-column field="actions" label="Actions">
|
||||||
<a href="#" class="grid-action"
|
<a href="#" class="grid-action"
|
||||||
@click.prevent="showEditItemDialog(props.index)">
|
@click.prevent="showEditItemDialog(props.index)">
|
||||||
|
@ -734,6 +754,12 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
productUPCKeyDown(event) {
|
||||||
|
if (event.which == 13) { // Enter
|
||||||
|
this.fetchProductByUPC()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
productChanged(uuid) {
|
productChanged(uuid) {
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
this.productUUID = uuid
|
this.productUUID = uuid
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -52,6 +52,8 @@ class CustomerOrderBatchView(BatchMasterView):
|
||||||
'total_price',
|
'total_price',
|
||||||
'created',
|
'created',
|
||||||
'created_by',
|
'created_by',
|
||||||
|
'executed',
|
||||||
|
'executed_by',
|
||||||
]
|
]
|
||||||
|
|
||||||
form_fields = [
|
form_fields = [
|
||||||
|
|
|
@ -32,7 +32,7 @@ import six
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from rattail import pod
|
from rattail import pod
|
||||||
from rattail.db import api, model
|
from rattail.db import model
|
||||||
from rattail.util import pretty_quantity
|
from rattail.util import pretty_quantity
|
||||||
from rattail.batch import get_batch_handler
|
from rattail.batch import get_batch_handler
|
||||||
|
|
||||||
|
@ -263,7 +263,8 @@ class CustomerOrderView(MasterView):
|
||||||
if not upc:
|
if not upc:
|
||||||
return {'error': "Must specify a product 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:
|
if not product:
|
||||||
return {'error': "Product not found"}
|
return {'error': "Product not found"}
|
||||||
|
|
||||||
|
@ -299,14 +300,15 @@ class CustomerOrderView(MasterView):
|
||||||
|
|
||||||
# Case
|
# Case
|
||||||
case_text = None
|
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(
|
case_text = "{} (× ?? {})".format(
|
||||||
self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE],
|
self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE],
|
||||||
unit_name)
|
unit_name)
|
||||||
elif product.case_size > 1:
|
elif case_size > 1:
|
||||||
case_text = "{} (× {} {})".format(
|
case_text = "{} (× {} {})".format(
|
||||||
self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE],
|
self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE],
|
||||||
pretty_quantity(product.case_size),
|
pretty_quantity(case_size),
|
||||||
unit_name)
|
unit_name)
|
||||||
if case_text:
|
if case_text:
|
||||||
choices.append({'key': self.enum.UNIT_OF_MEASURE_CASE,
|
choices.append({'key': self.enum.UNIT_OF_MEASURE_CASE,
|
||||||
|
@ -334,6 +336,9 @@ class CustomerOrderView(MasterView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def normalize_row(self, row):
|
def normalize_row(self, row):
|
||||||
|
product = row.product
|
||||||
|
department = product.department if product else None
|
||||||
|
cost = product.cost if product else None
|
||||||
data = {
|
data = {
|
||||||
'uuid': row.uuid,
|
'uuid': row.uuid,
|
||||||
'sequence': row.sequence,
|
'sequence': row.sequence,
|
||||||
|
@ -344,7 +349,7 @@ class CustomerOrderView(MasterView):
|
||||||
'product_brand': row.product_brand,
|
'product_brand': row.product_brand,
|
||||||
'product_description': row.product_description,
|
'product_description': row.product_description,
|
||||||
'product_size': row.product_size,
|
'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,
|
'product_weighed': row.product_weighed,
|
||||||
|
|
||||||
'case_quantity': pretty_quantity(row.case_quantity),
|
'case_quantity': pretty_quantity(row.case_quantity),
|
||||||
|
@ -352,7 +357,10 @@ class CustomerOrderView(MasterView):
|
||||||
'units_ordered': pretty_quantity(row.units_ordered),
|
'units_ordered': pretty_quantity(row.units_ordered),
|
||||||
'order_quantity': pretty_quantity(row.order_quantity),
|
'order_quantity': pretty_quantity(row.order_quantity),
|
||||||
'order_uom': row.order_uom,
|
'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': 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,
|
'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)}
|
'batch': self.normalize_batch(batch)}
|
||||||
|
|
||||||
def submit_new_order(self, batch, data):
|
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:
|
if not result:
|
||||||
return {'error': "Batch failed to execute"}
|
return {'error': "Batch failed to execute"}
|
||||||
|
|
||||||
|
@ -478,6 +486,9 @@ class CustomerOrderView(MasterView):
|
||||||
|
|
||||||
return {'ok': True, 'next_url': next_url}
|
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
|
# TODO: deprecate / remove this
|
||||||
CustomerOrdersView = CustomerOrderView
|
CustomerOrdersView = CustomerOrderView
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue