Show user warning if "add item to custorder" fails

specifically, if user enters alpha chars for cost/price fields
This commit is contained in:
Lance Edgar 2023-10-24 17:48:08 -05:00
parent f708cb0b25
commit e308108bf7
2 changed files with 6 additions and 1 deletions

View file

@ -2124,6 +2124,8 @@
this.itemDialogSaving = false this.itemDialogSaving = false
this.showingItemDialog = false this.showingItemDialog = false
}, response => {
this.itemDialogSaving = false
}) })
}, },
}, },

View file

@ -864,7 +864,10 @@ class CustomerOrderView(MasterView):
for field in ('unit_cost', 'regular_price_amount', 'case_size'): for field in ('unit_cost', 'regular_price_amount', 'case_size'):
if field in pending_info: if field in pending_info:
try:
pending_info[field] = decimal.Decimal(pending_info[field]) pending_info[field] = decimal.Decimal(pending_info[field])
except decimal.InvalidOperation:
return {'error': f"Invalid entry for field: {field}"}
pending_info['user'] = self.request.user pending_info['user'] = self.request.user