diff --git a/backend/views/core/invoices/edit.py b/backend/views/core/invoices/edit.py index 550aef53c..8283e8ec2 100644 --- a/backend/views/core/invoices/edit.py +++ b/backend/views/core/invoices/edit.py @@ -104,7 +104,7 @@ def edit_invoice(request: HttpRequest, invoice_id): client_to_id = request.POST.get("selected_client") try: client_to_obj = Client.objects.get(id=client_to_id, user=request.user) - except Client.DoesNotExist: + except (Client.DoesNotExist, ValueError): client_to_obj = None if client_to_obj: @@ -139,8 +139,9 @@ def edit_invoice(request: HttpRequest, invoice_id): invoice.save() + messages.success(request, "Invoice edited") + if request.htmx: - messages.success(request, "Invoice edited") return render(request, "base/toasts.html") return invoice_edit_page_get(request, invoice_id)