Improve error handling when executing a custorder batch
This commit is contained in:
parent
6e15d59a84
commit
3a10a4bcb7
|
@ -483,7 +483,8 @@
|
|||
@click="showAddItemDialog()">
|
||||
Add Item
|
||||
</b-button>
|
||||
<b-button icon-pack="fas"
|
||||
<b-button v-if="contactUUID"
|
||||
icon-pack="fas"
|
||||
icon-left="fas fa-plus"
|
||||
@click="showAddPastItem()">
|
||||
Add Past Item
|
||||
|
@ -1239,6 +1240,9 @@
|
|||
type: 'is-danger',
|
||||
duration: 2000, // 2 seconds
|
||||
})
|
||||
if (failure) {
|
||||
failure(response)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -1250,20 +1254,13 @@
|
|||
}
|
||||
|
||||
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
|
||||
if (response.data.next_url) {
|
||||
location.href = response.data.next_url
|
||||
} else {
|
||||
if (response.data.next_url) {
|
||||
location.href = response.data.next_url
|
||||
} else {
|
||||
location.reload()
|
||||
}
|
||||
location.reload()
|
||||
}
|
||||
}, response => {
|
||||
this.submittingOrder = false
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -779,9 +779,13 @@ class CustomerOrderView(MasterView):
|
|||
'batch': self.normalize_batch(batch)}
|
||||
|
||||
def submit_new_order(self, batch, data):
|
||||
result = self.execute_new_order_batch(batch, data)
|
||||
if not result:
|
||||
return {'error': "Batch failed to execute"}
|
||||
try:
|
||||
result = self.execute_new_order_batch(batch, data)
|
||||
except Exception as error:
|
||||
return {'error': six.text_type(error)}
|
||||
else:
|
||||
if not result:
|
||||
return {'error': "Batch failed to execute"}
|
||||
|
||||
next_url = None
|
||||
if isinstance(result, model.CustomerOrder):
|
||||
|
|
Loading…
Reference in a new issue