Improve error handling when executing a custorder batch

This commit is contained in:
Lance Edgar 2021-11-11 13:37:10 -06:00
parent 6e15d59a84
commit 3a10a4bcb7
2 changed files with 17 additions and 16 deletions

View file

@ -483,7 +483,8 @@
@click="showAddItemDialog()"> @click="showAddItemDialog()">
Add Item Add Item
</b-button> </b-button>
<b-button icon-pack="fas" <b-button v-if="contactUUID"
icon-pack="fas"
icon-left="fas fa-plus" icon-left="fas fa-plus"
@click="showAddPastItem()"> @click="showAddPastItem()">
Add Past Item Add Past Item
@ -1239,6 +1240,9 @@
type: 'is-danger', type: 'is-danger',
duration: 2000, // 2 seconds duration: 2000, // 2 seconds
}) })
if (failure) {
failure(response)
}
}) })
}, },
@ -1250,20 +1254,13 @@
} }
this.submitBatchData(params, response => { this.submitBatchData(params, response => {
if (response.data.error) {
this.$buefy.toast.open({
message: "Submit failed: " + response.data.error,
type: 'is-danger',
duration: 2000, // 2 seconds
})
this.submittingOrder = false
} else {
if (response.data.next_url) { if (response.data.next_url) {
location.href = response.data.next_url location.href = response.data.next_url
} else { } else {
location.reload() location.reload()
} }
} }, response => {
this.submittingOrder = false
}) })
}, },

View file

@ -779,7 +779,11 @@ 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):
try:
result = self.execute_new_order_batch(batch, data) result = self.execute_new_order_batch(batch, data)
except Exception as error:
return {'error': six.text_type(error)}
else:
if not result: if not result:
return {'error': "Batch failed to execute"} return {'error': "Batch failed to execute"}