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) { if (response.data.next_url) {
this.$buefy.toast.open({ location.href = response.data.next_url
message: "Submit failed: " + response.data.error,
type: 'is-danger',
duration: 2000, // 2 seconds
})
this.submittingOrder = false
} else { } else {
if (response.data.next_url) { location.reload()
location.href = response.data.next_url
} else {
location.reload()
}
} }
}, response => {
this.submittingOrder = false
}) })
}, },

View file

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