Auto-select Quantity tab when editing item for new custorder

also be a little smarter on error when user selects an item
This commit is contained in:
Lance Edgar 2021-11-06 17:56:35 -05:00
parent 43bbc2a29e
commit ddb05afe6b
2 changed files with 25 additions and 6 deletions

View file

@ -489,6 +489,7 @@
<div class="card-content"> <div class="card-content">
<b-tabs type="is-boxed is-toggle" <b-tabs type="is-boxed is-toggle"
v-model="itemDialogTabIndex"
:animated="false"> :animated="false">
<b-tab-item label="Product"> <b-tab-item label="Product">
@ -816,6 +817,7 @@
items: ${json.dumps(order_items)|n}, items: ${json.dumps(order_items)|n},
editingItem: null, editingItem: null,
showingItemDialog: false, showingItemDialog: false,
itemDialogTabIndex: 0,
productIsKnown: true, productIsKnown: true,
productUUID: null, productUUID: null,
productDisplay: null, productDisplay: null,
@ -1105,7 +1107,7 @@
}) })
}, },
submitBatchData(params, callback) { submitBatchData(params, success, failure) {
let url = ${json.dumps(request.current_route_url())|n} let url = ${json.dumps(request.current_route_url())|n}
let headers = { let headers = {
@ -1115,8 +1117,17 @@
## TODO: should find a better way to handle CSRF token ## TODO: should find a better way to handle CSRF token
this.$http.post(url, params, {headers: headers}).then((response) => { this.$http.post(url, params, {headers: headers}).then((response) => {
if (callback) { if (response.data.error) {
callback(response) this.$buefy.toast.open({
message: response.data.error,
type: 'is-danger',
duration: 2000, // 2 seconds
})
if (failure) {
failure(response)
}
} else if (success) {
success(response)
} }
}, response => { }, response => {
this.$buefy.toast.open({ this.$buefy.toast.open({
@ -1377,6 +1388,7 @@
this.productPriceNeedsConfirmation = false this.productPriceNeedsConfirmation = false
% endif % endif
this.itemDialogTabIndex = 0
this.showingItemDialog = true this.showingItemDialog = true
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.productAutocomplete.focus() this.$refs.productAutocomplete.focus()
@ -1405,6 +1417,7 @@
this.productPriceNeedsConfirmation = row.price_needs_confirmation this.productPriceNeedsConfirmation = row.price_needs_confirmation
% endif % endif
this.itemDialogTabIndex = 1
this.showingItemDialog = true this.showingItemDialog = true
}, },
@ -1492,6 +1505,8 @@
% if product_price_may_be_questionable: % if product_price_may_be_questionable:
this.productPriceNeedsConfirmation = false this.productPriceNeedsConfirmation = false
% endif % endif
}, response => {
this.clearProduct()
}) })
} else { } else {
this.clearProduct() this.clearProduct()

View file

@ -560,7 +560,11 @@ class CustomerOrderView(MasterView):
return self.handler.uom_choices_for_product(product) return self.handler.uom_choices_for_product(product)
def info_for_product(self, batch, data, product): def info_for_product(self, batch, data, product):
try:
info = self.handler.get_product_info(batch, product) info = self.handler.get_product_info(batch, product)
except Exception as error:
return {'error': six.text_type(error)}
else:
info['url'] = self.request.route_url('products.view', uuid=info['uuid']) info['url'] = self.request.route_url('products.view', uuid=info['uuid'])
return info return info